Просмотр исходного кода

Adding preferredContentSize (#2529)

* added the ability to change the backing controller's preferredContentSize through props.

* added some documentation outlining preferredContentSize and modalPresentationStyle properties
DavidCMurphy 7 лет назад
Родитель
Сommit
a5ff07faea
2 измененных файлов: 12 добавлений и 0 удалений
  1. 3
    0
      docs/styling-the-navigator.md
  2. 9
    0
      ios/RCCViewController.m

+ 3
- 0
docs/styling-the-navigator.md Просмотреть файл

@@ -99,6 +99,9 @@ this.props.navigator.setStyle({
99 99
   topBarShadowOpacity: 0.5, // Sets shadow opacity on the navbar, Works only when topBarElevationShadowEnabled: true
100 100
   topBarShadowOffset: 12, // Sets shadow offset on the navbar, Works only when topBarElevationShadowEnabled: true
101 101
   topBarShadowRadius: 3 // Sets shadow radius on the navbar, Works only when topBarElevationShadowEnabled: true
102
+
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' and 'fullScreen'. 
102 105
   
103 106
   // Android only
104 107
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.

+ 9
- 0
ios/RCCViewController.m Просмотреть файл

@@ -724,6 +724,15 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
724 724
   } else {
725 725
     self._statusBarHidden = NO;
726 726
   }
727
+  
728
+  NSDictionary *preferredContentSize = self.navigatorStyle[@"preferredContentSize"];
729
+  if (preferredContentSize) {
730
+    NSNumber *width = preferredContentSize[@"width"];
731
+    NSNumber *height = preferredContentSize[@"height"];
732
+    if (width && height) {
733
+      self.preferredContentSize = CGSizeMake([width floatValue], [height floatValue]);
734
+    }
735
+  }
727 736
 }
728 737
 
729 738
 - (BOOL)hidesBottomBarWhenPushed