问题
Our app supports RTL language like Arabic, Persian.
After iOS 9 the navigation controller and tab bar controller behavior has been changed. I found only this link ios-9-disable-support-for-right-to-left-language for solve this problem
I write this code in my appDelegate
and it works fine and navigation bar and tab bar set as LTR.
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) {
[[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[[UITabBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}
But my problem is: I can't change interactive pop gesture Direction .
回答1:
I was struggling with same problem and finally found solution
you just need to set SemanticContentAttribute for navigationController.view
in the rootViewController's viewDidLoad:
[self.navigationController.view setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
[self.navigationController.navigationBar setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
回答2:
In Swift
navigationController?.view.semanticContentAttribute = .forceRightToLeft
navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
回答3:
If your are creating custom pop up, two way you can handle this.
Define a macro in .h file to detect whether it is RTL language or not in runtime.
define IS_RTL [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft
then create custom layout according if IS_RTL.Like
if (IS_RTL)
//Do Arabic Implementation
else
//Do other language implementation
- If you are creating UI from Storyboard, the set constraint to Lead or Trailing space and value of First Item will be Respect Language Direction
来源:https://stackoverflow.com/questions/32932463/rtl-language-behavior-in-ios-9