Browse Source

Force translucent on iOS 12 when background is transparent

yogevbd 4 years ago
parent
commit
2ad41f3adb

+ 2
- 0
lib/ios/TopBarPresenter.m View File

72
     if (self.transparent) {
72
     if (self.transparent) {
73
         [self setBackgroundColorTransparent];
73
         [self setBackgroundColorTransparent];
74
     } else if (_backgroundColor) {
74
     } else if (_backgroundColor) {
75
+        self.navigationController.navigationBar.translucent = NO;
75
         self.navigationController.navigationBar.barTintColor = _backgroundColor;
76
         self.navigationController.navigationBar.barTintColor = _backgroundColor;
76
     } else if (_translucent) {
77
     } else if (_translucent) {
77
         self.navigationController.navigationBar.translucent = YES;
78
         self.navigationController.navigationBar.translucent = YES;
83
 
84
 
84
 - (void)setBackgroundColorTransparent {
85
 - (void)setBackgroundColorTransparent {
85
     self.navigationController.navigationBar.barTintColor = UIColor.clearColor;
86
     self.navigationController.navigationBar.barTintColor = UIColor.clearColor;
87
+    self.navigationController.navigationBar.translucent = YES;
86
     self.navigationController.navigationBar.shadowImage = [UIImage new];
88
     self.navigationController.navigationBar.shadowImage = [UIImage new];
87
     [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
89
     [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
88
 }
90
 }

+ 2
- 1
playground/ios/NavigationIOS12Tests/RNNRootViewControllerTest.m View File

185
 	
185
 	
186
 	nav.navigationBar.barTintColor = UIColor.clearColor;
186
 	nav.navigationBar.barTintColor = UIColor.clearColor;
187
 	XCTAssertTrue([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
187
 	XCTAssertTrue([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
188
+	XCTAssertTrue(nav.navigationBar.isTranslucent);
188
 }
189
 }
189
 
190
 
190
 -(void)testTopBarTransparent_BOOL_false {
191
 -(void)testTopBarTransparent_BOOL_false {
192
 	__unused RNNStackController* nav = [self createNavigationController];
193
 	__unused RNNStackController* nav = [self createNavigationController];
193
 	self.options.topBar.background.color = [[Color alloc] initWithValue:inputColor];
194
 	self.options.topBar.background.color = [[Color alloc] initWithValue:inputColor];
194
 	[self.uut viewWillAppear:false];
195
 	[self.uut viewWillAppear:false];
195
-
196
+	XCTAssertFalse(nav.navigationBar.isTranslucent);
196
 	XCTAssertFalse([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
197
 	XCTAssertFalse([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
197
 }
198
 }
198
 
199