瀏覽代碼

Allow customTitleView and customNavigationBarView to be transparent (#2908)

frankenthumbs 6 年之前
父節點
當前提交
193f8ed334
共有 1 個檔案被更改,包括 11 行新增7 行删除
  1. 11
    7
      lib/ios/RNNRootViewController.m

+ 11
- 7
lib/ios/RNNRootViewController.m 查看文件

@@ -27,11 +27,11 @@
27 27
 	self.animator = [[RNNAnimator alloc] initWithTransitionOptions:self.options.customTransition];
28 28
 	self.creator = creator;
29 29
 	self.isExternalComponent = isExternalComponent;
30
-	
30
+
31 31
 	if (!self.isExternalComponent) {
32 32
 		self.view = [creator createRootView:self.componentName rootViewId:self.componentId];
33 33
 	}
34
-	
34
+
35 35
 	[[NSNotificationCenter defaultCenter] addObserver:self
36 36
 											 selector:@selector(onJsReload)
37 37
 												 name:RCTJavaScriptWillStartLoadingNotification
@@ -40,11 +40,11 @@
40 40
 
41 41
 	return self;
42 42
 }
43
-	
43
+
44 44
 -(void)viewWillAppear:(BOOL)animated{
45 45
 	[super viewWillAppear:animated];
46 46
 	[self.options applyOn:self];
47
-	
47
+
48 48
 	[self setCustomNavigationTitleView];
49 49
 	[self setCustomNavigationBarView];
50 50
 	[self setCustomNavigationComponentBackground];
@@ -75,8 +75,10 @@
75 75
 - (void)setCustomNavigationTitleView {
76 76
 	if (self.options.topBar.title.component) {
77 77
 		RCTRootView *reactView = (RCTRootView*)[_creator createRootView:self.options.topBar.title.component rootViewId:self.options.topBar.title.component];
78
-		
78
+
79 79
 		RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:self.options.topBar.title.componentAlignment];
80
+        reactView.backgroundColor = UIColor.clearColor;
81
+		titleView.backgroundColor = UIColor.clearColor;
80 82
 		self.navigationItem.titleView = titleView;
81 83
 	}
82 84
 }
@@ -84,8 +86,10 @@
84 86
 - (void)setCustomNavigationBarView {
85 87
 	if (self.options.topBar.componentName) {
86 88
 		RCTRootView *reactView = (RCTRootView*)[_creator createRootView:self.options.topBar.componentName rootViewId:@"navBar"];
87
-		
89
+
88 90
 		RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
91
+		reactView.backgroundColor = UIColor.clearColor;
92
+		titleView.backgroundColor = UIColor.clearColor;
89 93
 		[self.navigationController.navigationBar addSubview:titleView];
90 94
 	}
91 95
 }
@@ -93,7 +97,7 @@
93 97
 - (void)setCustomNavigationComponentBackground {
94 98
 	if (self.options.topBar.backgroundComponentName) {
95 99
 		RCTRootView *reactView = (RCTRootView*)[_creator createRootView:self.options.topBar.backgroundComponentName rootViewId:@"navBarBackground"];
96
-		
100
+
97 101
 		RNNCustomTitleView *titleView = [[RNNCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
98 102
 		[self.navigationController.navigationBar insertSubview:titleView atIndex:1];
99 103
 	}