Browse Source

Fix top bar component layout frame size (#5015)

* Fix top bar component layout frame size

* Update RNNReactView.m
Yogev Ben David 5 years ago
parent
commit
1993b93c2e
No account linked to committer's email address
2 changed files with 5 additions and 14 deletions
  1. 4
    0
      lib/ios/RNNReactView.m
  2. 1
    14
      lib/ios/RNNViewControllerPresenter.m

+ 4
- 0
lib/ios/RNNReactView.m View File

@@ -45,6 +45,10 @@
45 45
 		self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
46 46
 	} else {
47 47
 		self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
48
+		__weak RNNReactView *weakSelf = self;
49
+		[self setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicSize) {
50
+			[weakSelf setFrame:CGRectMake(0, 0, intrinsicSize.width, intrinsicSize.height)];
51
+		}];
48 52
 	}
49 53
 }
50 54
 

+ 1
- 14
lib/ios/RNNViewControllerPresenter.m View File

@@ -166,22 +166,9 @@
166 166
 	if (options.topBar.title.component.name.hasValue) {
167 167
 		_customTitleView = (RNNReactView*)[_componentRegistry createComponentIfNotExists:options.topBar.title.component parentComponentId:viewController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
168 168
 		_customTitleView.backgroundColor = UIColor.clearColor;
169
-		
170 169
 		NSString* alignment = [options.topBar.title.component.alignment getWithDefaultValue:@""];
171 170
 		[_customTitleView setAlignment:alignment];
172
-		
173
-		BOOL isCenter = [alignment isEqualToString:@"center"];
174
-		__weak RNNReactView *weakTitleView = _customTitleView;
175
-		CGRect frame = viewController.navigationController.navigationBar.bounds;
176
-		[_customTitleView setFrame:frame];
177
-		[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
178
-			if (isCenter) {
179
-				[weakTitleView setFrame:CGRectMake(0, 0, intrinsicContentSize.width, intrinsicContentSize.height)];
180
-			} else {
181
-				[weakTitleView setFrame:frame];
182
-			}
183
-		}];
184
-		
171
+
185 172
 		viewController.navigationItem.titleView = _customTitleView;
186 173
 	} else {
187 174
 		[_customTitleView removeFromSuperview];