diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index a5a84a1f7f..34a5c62c8e 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -494,8 +494,17 @@ + (void)updateViewController:(UIViewController *)vc config.direction == UISemanticContentAttributeForceRightToLeft) && // iOS 12 cancels swipe gesture when direction is changed. See #1091 navctr.view.semanticContentAttribute != config.direction) { + // This is needed for swipe back gesture direction navctr.view.semanticContentAttribute = config.direction; + + // This is responsible for the direction of the navigationBar and its contents navctr.navigationBar.semanticContentAttribute = config.direction; + [[UIButton appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]] + setSemanticContentAttribute:config.direction]; + [[UIView appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]] + setSemanticContentAttribute:config.direction]; + [[UISearchBar appearanceWhenContainedInInstancesOfClasses:@[ navctr.navigationBar.class ]] + setSemanticContentAttribute:config.direction]; } if (shouldHide) { @@ -606,8 +615,6 @@ + (void)updateViewController:(UIViewController *)vc #endif } #if !TARGET_OS_TV - // Workaround for the wrong rotation of back button arrow in RTL mode. - navitem.hidesBackButton = true; navitem.hidesBackButton = config.hideBackButton; #endif navitem.leftBarButtonItem = nil; @@ -665,13 +672,6 @@ + (void)updateViewController:(UIViewController *)vc } } - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), dispatch_get_main_queue(), ^{ - // Position the contents in the navigation bar, regarding to the direction. - for (UIView *view in navctr.navigationBar.subviews) { - view.semanticContentAttribute = config.direction; - } - }); - // This assignment should be done after `navitem.titleView = ...` assignment (iOS 16.0 bug). // See: https://github.com/software-mansion/react-native-screens/issues/1570 (comments) navitem.title = config.title;