阿拉伯文文本对齐
问题描述:
我使用的UITextView在SWIFT 3.0,我想同时支持英语和阿拉伯语的UITextView语言。当我在UiTextView中设置阿拉伯语文本时,它从左向右对齐,而不是向右对齐。阿拉伯文文本对齐
我已经设置了对齐到故事板自然,但它无法正常工作。如果是阿拉伯文字,我想在英文的情况下从左到右显示文字,从右到左显示文字。
我怎样才能实现它在SWIFT 3.0?
答
你可以试试这个代码:
let currentDeviceLanguage = Locale.current.languageCode
if let currentDeviceLanguage = Locale.current.languageCode {
print("currentLanguage", currentDeviceLanguage)
if currentDeviceLanguage == "he" {
UIView.appearance().semanticContentAttribute = .forceRightToLeft
} else {
UIView.appearance().semanticContentAttribute = .forceLeftToRight
}
}
你能证明你试过代码 –
@ SandeepAgrawal..have您在项目 –
添加阿拉伯字体@ Anbu.Karthik请参阅附件图像。 –