Bladeren bron

fixes react component as titleView

yogevbd 6 jaren geleden
bovenliggende
commit
28322c71ce
2 gewijzigde bestanden met toevoegingen van 8 en 4 verwijderingen
  1. 2
    2
      lib/ios/RNNReactRootView.m
  2. 6
    2
      lib/ios/RNNRootViewController.m

+ 2
- 2
lib/ios/RNNReactRootView.m Bestand weergeven

@@ -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 Bestand weergeven

@@ -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) {