Skip to content

Commit 1993b93

Browse files
authoredApr 23, 2019
Fix top bar component layout frame size (#5015)
* Fix top bar component layout frame size * Update RNNReactView.m
1 parent 0e888fb commit 1993b93

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed
 

‎lib/ios/RNNReactView.m

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ - (void)setAlignment:(NSString *)alignment {
4545
self.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
4646
} else {
4747
self.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
48+
__weak RNNReactView *weakSelf = self;
49+
[self setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicSize) {
50+
[weakSelf setFrame:CGRectMake(0, 0, intrinsicSize.width, intrinsicSize.height)];
51+
}];
4852
}
4953
}
5054

‎lib/ios/RNNViewControllerPresenter.m

+1-14
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,9 @@ - (void)setCustomNavigationTitleView:(RNNNavigationOptions *)options perform:(RN
166166
if (options.topBar.title.component.name.hasValue) {
167167
_customTitleView = (RNNReactView*)[_componentRegistry createComponentIfNotExists:options.topBar.title.component parentComponentId:viewController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
168168
_customTitleView.backgroundColor = UIColor.clearColor;
169-
170169
NSString* alignment = [options.topBar.title.component.alignment getWithDefaultValue:@""];
171170
[_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+
185172
viewController.navigationItem.titleView = _customTitleView;
186173
} else {
187174
[_customTitleView removeFromSuperview];

0 commit comments

Comments
 (0)