Parcourir la source

fixes react component as titleView

yogevbd il y a 6 ans
Parent
révision
28322c71ce
2 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. 2
    2
      lib/ios/RNNReactRootView.m
  2. 6
    2
      lib/ios/RNNRootViewController.m

+ 2
- 2
lib/ios/RNNReactRootView.m Voir le fichier

@@ -15,9 +15,9 @@
15 15
 
16 16
 - (void)setAlignment:(NSString *)alignment {
17 17
 	if ([alignment isEqualToString:@"fill"]) {
18
-		self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
19
-	} else {
20 18
 		self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
19
+	} else {
20
+		self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
21 21
 	}
22 22
 }
23 23
 

+ 6
- 2
lib/ios/RNNRootViewController.m Voir le fichier

@@ -139,16 +139,20 @@
139 139
 	if (!_customTitleView) {
140 140
 		if (self.options.topBar.title.component.name) {
141 141
 			_customTitleView = (RNNReactRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
142
-			_customTitleView.backgroundColor = UIColor.clearColor;
142
+			_customTitleView.backgroundColor = UIColor.redColor;
143 143
 			[_customTitleView setAlignment:self.options.topBar.title.component.alignment];
144 144
 			BOOL isCenter = [self.options.topBar.title.component.alignment isEqualToString:@"center"];
145 145
 			__weak RNNReactRootView *weakTitleView = _customTitleView;
146
+			CGRect frame = self.navigationController.navigationBar.frame;
147
+			[_customTitleView setFrame:frame];
146 148
 			[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
147 149
 				if (isCenter) {
148 150
 					[weakTitleView setFrame:CGRectMake(0, 0, intrinsicContentSize.width, intrinsicContentSize.height)];
151
+				} else {
152
+					[weakTitleView setFrame:frame];
149 153
 				}
150 154
 			}];
151
-			[_customTitleView setFrame:self.navigationController.navigationBar.frame];
155
+			
152 156
 			self.navigationItem.titleView = _customTitleView;
153 157
 		}
154 158
 	} else if (_customTitleView && _customTitleView.superview == nil) {