阿拉伯文文本对齐

问题描述:

enter image description here我使用的UITextView在SWIFT 3.0,我想同时支持英语和阿拉伯语的UITextView语言。当我在UiTextView中设置阿拉伯语文本时,它从左向右对齐,而不是向右对齐。阿拉伯文文本对齐

我已经设置了对齐到故事板自然,但它无法正常工作。如果是阿拉伯文字,我想在英文的情况下从左到右显示文字,从右到左显示文字。

我怎样才能实现它在SWIFT 3.0?

+0

你能证明你试过代码 –

+0

@ SandeepAgrawal..have您在项目 –

+0

添加阿拉伯字体@ Anbu.Karthik请参阅附件图像。 –

你可以试试这个代码:

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 
} 

}