I disable views rotation (process when Hebrew language is selected and all views change their positions from left to right) when phone has RightToLeft localization:
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")){
    if (RightToLeft) {
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
        [[UINavigationBar appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
    }
}
Everything looks fine, but I need to swipe right-to-left to return in previous view controller. How can I set left to right swipe direction for navigation between ViewControllers?
I finally got one working for those who subclassed the UINavigationController class. You should do something like this :
final class TestNavigationController: UINavigationController, UINavigationControllerDelegate {
    override func viewDidLoad() {
         super.viewDidLoad()
         self.delegate = self
    }
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
         navigationController.view.semanticContentAttribute = UIView.isRightToLeft() ? .forceRightToLeft : .forceLeftToRight
         navigationController.navigationBar.semanticContentAttribute = UIView.isRightToLeft() ? .forceRightToLeft : .forceLeftToRight
    }
}
extension UIView {
    static func isRightToLeft() -> Bool {
        return UIView.appearance().semanticContentAttribute == .forceRightToLeft
    }
}
Dynamically, your NavigationController will adapt to the forced semantic content attribute. I hope it helps. Let me know if you have any problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With