@@ -612,23 +612,7 @@ + (void)updateViewController:(UIViewController *)vc
612612 }
613613
614614 [navctr setNavigationBarHidden: shouldHide animated: animated];
615-
616- if ((config.direction == UISemanticContentAttributeForceLeftToRight ||
617- config.direction == UISemanticContentAttributeForceRightToLeft) &&
618- // iOS 12 cancels swipe gesture when direction is changed. See #1091
619- navctr.view .semanticContentAttribute != config.direction ) {
620- // This is needed for swipe back gesture direction
621- navctr.view .semanticContentAttribute = config.direction ;
622-
623- // This is responsible for the direction of the navigationBar and its contents
624- navctr.navigationBar .semanticContentAttribute = config.direction ;
625- [[UIButton appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
626- setSemanticContentAttribute: config.direction];
627- [[UIView appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
628- setSemanticContentAttribute: config.direction];
629- [[UISearchBar appearanceWhenContainedInInstancesOfClasses: @[ navctr.navigationBar.class ]]
630- setSemanticContentAttribute: config.direction];
631- }
615+ [config applySemanticContentAttributeIfNeededToNavCtrl: navctr];
632616
633617 if (shouldHide) {
634618 navitem.title = config.title ;
@@ -848,6 +832,26 @@ + (void)updateViewController:(UIViewController *)vc
848832 }
849833}
850834
835+ - (void )applySemanticContentAttributeIfNeededToNavCtrl: (UINavigationController *)navCtrl
836+ {
837+ if ((self.direction == UISemanticContentAttributeForceLeftToRight ||
838+ self.direction == UISemanticContentAttributeForceRightToLeft) &&
839+ // iOS 12 cancels swipe gesture when direction is changed. See #1091
840+ navCtrl.view .semanticContentAttribute != self.direction ) {
841+ // This is needed for swipe back gesture direction
842+ navCtrl.view .semanticContentAttribute = self.direction ;
843+
844+ // This is responsible for the direction of the navigationBar and its contents
845+ navCtrl.navigationBar .semanticContentAttribute = self.direction ;
846+ [[UIButton appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
847+ setSemanticContentAttribute: self .direction];
848+ [[UIView appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
849+ setSemanticContentAttribute: self .direction];
850+ [[UISearchBar appearanceWhenContainedInInstancesOfClasses: @[ navCtrl.navigationBar.class ]]
851+ setSemanticContentAttribute: self .direction];
852+ }
853+ }
854+
851855RNS_IGNORE_SUPER_CALL_BEGIN
852856- (void )insertReactSubview: (RNSScreenStackHeaderSubview *)subview atIndex: (NSInteger )atIndex
853857{
0 commit comments