Browse Source

Allow customTitleView and customNavigationBarView to be transparent (#2908)

frankenthumbs 6 years ago
parent
commit
193f8ed334
1 changed files with 11 additions and 7 deletions
  1. 11
    7
      lib/ios/RNNRootViewController.m

+ 11
- 7
lib/ios/RNNRootViewController.m View File

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