Explorar el Código

Add support for prefersLargeTitles in iOS 11 (#2593)

Hammad Jutt hace 6 años
padre
commit
d9f267c326
Se han modificado 2 ficheros con 19 adiciones y 0 borrados
  1. 2
    0
      docs/styling-the-navigator.md
  2. 17
    0
      ios/RCCViewController.m

+ 2
- 0
docs/styling-the-navigator.md Ver fichero

@@ -103,6 +103,8 @@ this.props.navigator.setStyle({
103 103
   preferredContentSize: { width: 500, height: 500 } // Sets the preferred size for the view controller’s view.
104 104
   modalPresentationStyle: 'formSheet' // Sets the presentation style for modally presented view controllers. Supported styles are: 'formSheet', 'pageSheet', 'overFullScreen', 'overCurrentContext' and 'fullScreen'. 
105 105
   
106
+  largeTitle: false, // Sets the nav bar title to be in the larger iOS 11 style
107
+
106 108
   // Android only
107 109
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
108 110
   navBarTitleTextCentered: true, // default: false. centers the title.

+ 17
- 0
ios/RCCViewController.m Ver fichero

@@ -654,6 +654,23 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
654 654
       self.navigationItem.titleView.clipsToBounds = YES;
655 655
     }
656 656
   }
657
+
658
+  if (@available(iOS 11.0, *)) {
659
+    if ([self.navigationController.navigationBar respondsToSelector:@selector(setPrefersLargeTitles:)]) {
660
+      NSNumber *prefersLargeTitles = self.navigatorStyle[@"largeTitle"];
661
+      if (prefersLargeTitles) {
662
+        if ([prefersLargeTitles boolValue]) {
663
+          self.navigationController.navigationBar.prefersLargeTitles = YES;
664
+          self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
665
+        } else {
666
+          self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
667
+        }
668
+      } else {
669
+        self.navigationController.navigationBar.prefersLargeTitles = NO;
670
+        self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
671
+      }
672
+    }
673
+  }
657 674
 }
658 675
 
659 676