Browse Source

Add support for prefersLargeTitles in iOS 11 (#2593)

Hammad Jutt 6 years ago
parent
commit
d9f267c326
2 changed files with 19 additions and 0 deletions
  1. 2
    0
      docs/styling-the-navigator.md
  2. 17
    0
      ios/RCCViewController.m

+ 2
- 0
docs/styling-the-navigator.md View File

103
   preferredContentSize: { width: 500, height: 500 } // Sets the preferred size for the view controller’s view.
103
   preferredContentSize: { width: 500, height: 500 } // Sets the preferred size for the view controller’s view.
104
   modalPresentationStyle: 'formSheet' // Sets the presentation style for modally presented view controllers. Supported styles are: 'formSheet', 'pageSheet', 'overFullScreen', 'overCurrentContext' and 'fullScreen'. 
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
   // Android only
108
   // Android only
107
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
109
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
108
   navBarTitleTextCentered: true, // default: false. centers the title.
110
   navBarTitleTextCentered: true, // default: false. centers the title.

+ 17
- 0
ios/RCCViewController.m View File

654
       self.navigationItem.titleView.clipsToBounds = YES;
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