Просмотр исходного кода

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

frankenthumbs 6 лет назад
Родитель
Сommit
0e11b95f85
1 измененных файлов: 19 добавлений и 3 удалений
  1. 19
    3
      lib/ios/RNNRootViewController.m

+ 19
- 3
lib/ios/RNNRootViewController.m Просмотреть файл

@@ -100,7 +100,12 @@
100 100
 		} if ([self.navigationItem.title isKindOfClass:[RNNCustomTitleView class]] && !_customTitleView) {
101 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 111
 - (void)setCustomNavigationBarView {
@@ -115,7 +120,12 @@
115 120
 		} else if ([[self.navigationController.navigationBar.subviews lastObject] isKindOfClass:[RNNCustomTitleView class]] && !_customTopBar) {
116 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 131
 - (void)setCustomNavigationComponentBackground {
@@ -130,7 +140,13 @@
130 140
 			[[self.navigationController.navigationBar.subviews objectAtIndex:1] removeFromSuperview];
131 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 152
 -(BOOL)isCustomTransitioned {