Browse Source

fix header alignment

yogevbd 6 years ago
parent
commit
b8945a26d5
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      lib/ios/RNNRootViewController.m

+ 5
- 2
lib/ios/RNNRootViewController.m View File

10
 	RNNReactRootView* _customTitleView;
10
 	RNNReactRootView* _customTitleView;
11
 	UIView* _customTopBar;
11
 	UIView* _customTopBar;
12
 	UIView* _customTopBarBackground;
12
 	UIView* _customTopBarBackground;
13
+	BOOL _isBeingPresented;
13
 }
14
 }
14
 
15
 
15
 @property (nonatomic, strong) NSString* componentName;
16
 @property (nonatomic, strong) NSString* componentName;
60
 
61
 
61
 -(void)viewWillAppear:(BOOL)animated{
62
 -(void)viewWillAppear:(BOOL)animated{
62
 	[super viewWillAppear:animated];
63
 	[super viewWillAppear:animated];
64
+	_isBeingPresented = YES;
63
 	[self.options applyOn:self];
65
 	[self.options applyOn:self];
64
 }
66
 }
65
 
67
 
70
 
72
 
71
 - (void)viewWillDisappear:(BOOL)animated {
73
 - (void)viewWillDisappear:(BOOL)animated {
72
 	[super viewWillDisappear:animated];
74
 	[super viewWillDisappear:animated];
75
+	_isBeingPresented = NO;
73
 }
76
 }
74
 
77
 
75
 -(void)viewDidDisappear:(BOOL)animated {
78
 -(void)viewDidDisappear:(BOOL)animated {
136
 }
139
 }
137
 
140
 
138
 - (void)setCustomNavigationTitleView {
141
 - (void)setCustomNavigationTitleView {
139
-	if (!_customTitleView) {
142
+	if (!_customTitleView && _isBeingPresented) {
140
 		if (self.options.topBar.title.component.name) {
143
 		if (self.options.topBar.title.component.name) {
141
 			_customTitleView = (RNNReactRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
144
 			_customTitleView = (RNNReactRootView*)[_creator createRootViewFromComponentOptions:self.options.topBar.title.component];
142
 			_customTitleView.backgroundColor = UIColor.clearColor;
145
 			_customTitleView.backgroundColor = UIColor.clearColor;
143
 			[_customTitleView setAlignment:self.options.topBar.title.component.alignment];
146
 			[_customTitleView setAlignment:self.options.topBar.title.component.alignment];
144
 			BOOL isCenter = [self.options.topBar.title.component.alignment isEqualToString:@"center"];
147
 			BOOL isCenter = [self.options.topBar.title.component.alignment isEqualToString:@"center"];
145
 			__weak RNNReactRootView *weakTitleView = _customTitleView;
148
 			__weak RNNReactRootView *weakTitleView = _customTitleView;
146
-			CGRect frame = self.navigationController.navigationBar.frame;
149
+			CGRect frame = self.navigationController.navigationBar.bounds;
147
 			[_customTitleView setFrame:frame];
150
 			[_customTitleView setFrame:frame];
148
 			[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
151
 			[_customTitleView setRootViewDidChangeIntrinsicSize:^(CGSize intrinsicContentSize) {
149
 				if (isCenter) {
152
 				if (isCenter) {