Skip to content

Commit

Permalink
Force translucent on iOS 12 when background is transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd committed Dec 23, 2019
1 parent 1627219 commit 2ad41f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/ios/TopBarPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ - (void)updateBackgroundAppearance {
if (self.transparent) {
[self setBackgroundColorTransparent];
} else if (_backgroundColor) {
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barTintColor = _backgroundColor;
} else if (_translucent) {
self.navigationController.navigationBar.translucent = YES;
Expand All @@ -83,6 +84,7 @@ - (void)updateBackgroundAppearance {

- (void)setBackgroundColorTransparent {
self.navigationController.navigationBar.barTintColor = UIColor.clearColor;
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.shadowImage = [UIImage new];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,15 @@ -(void)testTopBarTransparent_BOOL_True {

nav.navigationBar.barTintColor = UIColor.clearColor;
XCTAssertTrue([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
XCTAssertTrue(nav.navigationBar.isTranslucent);
}

-(void)testTopBarTransparent_BOOL_false {
UIColor* inputColor = [RCTConvert UIColor:@(0xFFFF0000)];
__unused RNNStackController* nav = [self createNavigationController];
self.options.topBar.background.color = [[Color alloc] initWithValue:inputColor];
[self.uut viewWillAppear:false];

XCTAssertFalse(nav.navigationBar.isTranslucent);
XCTAssertFalse([nav.navigationBar.barTintColor isEqual:UIColor.clearColor]);
}

Expand Down

0 comments on commit 2ad41f3

Please sign in to comment.