Browse Source

Fix custom top bar from disappearing after a push (#3109)

frankenthumbs 6 years ago
parent
commit
0e11b95f85
1 changed files with 19 additions and 3 deletions
  1. 19
    3
      lib/ios/RNNRootViewController.m

+ 19
- 3
lib/ios/RNNRootViewController.m View File

100
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
100
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
101
 			self.navigationItem.title = nil;
101
 			self.navigationItem.title = nil;
102
 		}
102
 		}
103
-	}
103
+    } else if (_customTitleView.superview == nil) {
104
+        if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
105
+            self.navigationItem.title = nil;
106
+        }
107
+        self.navigationItem.titleView = _customTitleView;
108
+    }
104
 }
109
 }
105
 
110
 
106
 - (void)setCustomNavigationBarView {
111
 - (void)setCustomNavigationBarView {
115
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
120
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
116
 			[[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
121
 			[[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
117
 		}
122
 		}
118
-	}
123
+    } else if (_customTopBar.superview == nil) {
124
+        if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
125
+            [[self.navigationController.navigationBar.subviews lastObject] removeFromSuperview];
126
+        }
127
+        [self.navigationController.navigationBar addSubview:_customTopBar];
128
+    }
119
 }
129
 }
120
 
130
 
121
 - (void)setCustomNavigationComponentBackground {
131
 - (void)setCustomNavigationComponentBackground {
130
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
140
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
131
 			self.navigationController.navigationBar.clipsToBounds = NO;
141
 			self.navigationController.navigationBar.clipsToBounds = NO;
132
 		}
142
 		}
133
-	}
143
+    } if (_customTopBarBackground.superview == nil) {
144
+        if ([[self.navigationController.navigationBar.subviews objectAtIndex:1] isKindOfClass:[RNNCustomTitleView class]]) {
145
+            [[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
146
+        }
147
+        [self.navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
148
+        self.navigationController.navigationBar.clipsToBounds = YES;
149
+    }
134
 }
150
 }
135
 
151
 
136
 -(BOOL)isCustomTransitioned {
152
 -(BOOL)isCustomTransitioned {