瀏覽代碼

[v2][iOS] Fix display empty custom topBar background over valid custom background (#4823)

* [V2] [iOS] Fix iOS custom topBar background component

* Revert "[V2] [iOS] Fix iOS custom topBar background component"

This reverts commit aab340dbf5.

* Remove previous customTopBar and customTopBarBackground before new one
RoTTex 6 年之前
父節點
當前提交
6cb1e18a88
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. 6
    0
      lib/ios/RNNNavigationControllerPresenter.m

+ 6
- 0
lib/ios/RNNNavigationControllerPresenter.m 查看文件

181
 	if (options.topBar.component.name.hasValue) {
181
 	if (options.topBar.component.name.hasValue) {
182
 		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
182
 		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
183
 		
183
 		
184
+		if (_customTopBar) {
185
+			[_customTopBar removeFromSuperview];
186
+		}
184
 		_customTopBar = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
187
 		_customTopBar = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
185
 		reactView.backgroundColor = UIColor.clearColor;
188
 		reactView.backgroundColor = UIColor.clearColor;
186
 		_customTopBar.backgroundColor = UIColor.clearColor;
189
 		_customTopBar.backgroundColor = UIColor.clearColor;
202
 	if (options.topBar.background.component.name.hasValue) {
205
 	if (options.topBar.background.component.name.hasValue) {
203
 		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.background.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
206
 		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.background.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
204
 		
207
 		
208
+		if (_customTopBarBackground) {
209
+			[_customTopBarBackground removeFromSuperview];
210
+		}
205
 		_customTopBarBackground = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
211
 		_customTopBarBackground = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
206
 		[navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
212
 		[navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
207
 	} else {
213
 	} else {