Skip to content

Commit cd60960

Browse files
committed
fix(ios): remove toolbar background only on iOS 18 and older
- On iOS 26 there is no background by default. Also setting the `barStyle` to `UIBarStyleBlack` on iOS 26 resulted in changing the navigation buttons sometimes to dark or resulted in a black white flickering when the view appeared.
1 parent 69ec56c commit cd60960

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/ios/CDVWKInAppBrowser.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,19 @@ - (void)createViews
745745
[self.view addSubview:self.toolbarBackground];
746746

747747
self.toolbar = [UIToolbar new];
748-
// Remove default background for toolbar on iOS 18 and older, since we provide our own
749-
// backround
750-
// Remove background
751-
[self.toolbar setBackgroundImage:[UIImage new]
752-
forToolbarPosition:UIToolbarPositionAny
753-
barMetrics:UIBarMetricsDefault];
754-
// barStyle has to be set to UIBarStyleBlack, otherwhise there would be a gray line left,
755-
// after the background was removed
756-
self.toolbar.barStyle = UIBarStyleBlack;
748+
// Remove the toolbar background on iOS 18 and older
749+
if (@available(iOS 26.0, *)) {
750+
// Don't do anything on iOS 26 and newer, there is no background by default
751+
} else {
752+
// iOS 18 and older: Remove default background, since we provide our own backround
753+
// Remove background
754+
[self.toolbar setBackgroundImage:[UIImage new]
755+
forToolbarPosition:UIToolbarPositionAny
756+
barMetrics:UIBarMetricsDefault];
757+
// barStyle has to be set to UIBarStyleBlack, otherwhise there would be a gray line left,
758+
// after the background was removed
759+
self.toolbar.barStyle = UIBarStyleBlack;
760+
}
757761
// We add our own constraints, they should not be determined from the frame.
758762
self.toolbar.translatesAutoresizingMaskIntoConstraints = NO;
759763
[self.toolbarBackground addSubview:self.toolbar];

0 commit comments

Comments
 (0)