Skip to content

fix(ios): add custom toolbar background#1132

Open
GitToTheHub wants to merge 12 commits intomasterfrom
pr-ios-overlay-toolbar-address-label-on-webview
Open

fix(ios): add custom toolbar background#1132
GitToTheHub wants to merge 12 commits intomasterfrom
pr-ios-overlay-toolbar-address-label-on-webview

Conversation

@GitToTheHub
Copy link
Contributor

@GitToTheHub GitToTheHub commented Mar 4, 2026

Platforms affected

iOS

Motivation and Context

  • Edits on 6th March 2026: I reverted to a web view with none overlaying elements.
    • I had scrolling issues, when using an iFrame in the in-app browser and the toolbar and address bar overlays the webview. It's more safe to return to the old behaviour, when nothing overlays the webview.
  • Since iOS 26 the toolbar's background is not configurable anymore. To achieve this, a custom toolbar background is added, which is also used on iOS 18 and older to keep the code simple.

Description

iOS 26 Toolbar and Address bar at bottom

Default, when no options are set

master PR

The green color is from the underyling view which opened the in-app browser.

iOS 18 and older Toolbar and Address bar at bottom

Default, when no options are set

master PR

The green color is from the underyling view which opened the in-app browser.

iOS 26 Toolbar at top Address bar at bottom

master PR

The green color is from the underyling view which opened the in-app browser.

iOS 18 and older Toolbar at top Address bar at bottom

master PR

The green color is from the underyling view which opened the in-app browser.

Landscape Toolbar Top fix

On landscape, when the toolbar is at top it was too close to the top edge, which is fixed:

master PR

Set Custom Toolbar Background Color

Translucent None translucent
Set toolbarcolor=#FF0000 withtoolbartranslucent=yes which is the default Set toolbarcolor=#FF0000 and toolbartranslucent=no

Testing

All options were tested with the new layout:

  • Toolbar and address bar hidden
  • Toolbar visible at bottom or top, address bar hidden
  • Toolbar visible at bottom or top, address bar visible
  • Test on iOS 18 and iOS 26

Other changes

  • Fixes the toolbar is glued at the top on landscape
  • Address bar: Text is black by default and the background transparent white
    • Removed some unnecessary assigned properties
  • Toolbar: Removed some unnecessary assigned properties
  • doc(readme): change some wording for iOS option toolbartranslucent
  • Use always [NSLayoutConstraint activateConstraints:] to activate constraints

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

- The WebView top was constrained to safe area top, which made a transparent gap in the top safe area.
- breaking change: The site which should be dispayed in the in-app browser, have to care about the safe areas, otherwise it would be behind the camera and statusbar, which was before not the case
- Add background view for address label, so the address label can have paddings when a background is set
- Add semi-transparent background with round corners
- Add margins to the address background

Generated-By: GPT-5, XCode 26
- Overlay Toolbar and Address Bar over the WebView, so more web content can be shown and no background must be set for the Toolbar
- Insets are set for the WebView to to take the Toolbar and Address Bar into account, so the content can always be scrolled in a visible area
- Depends on #1128 and #1129
- It was a little bit dark with `alpha:0.4`. Changed it to `alpha:0.2`
- On iOS 26 the background color cannot be set anymore. To make this configurable, a custom background is added, which is also used on iOS 18 and older
- To make the code simple, the margin is added for portrait and landscape. To implement this clean, we would have to listen  to the orientation change and would have to change the constant in the constraint, which is to much work avoid the little margin on portait
- When using an iFrame in the in-app browser, there can be scrolling issues when the toolbar and address bar overlays the webview. It's more safe to return to the old behaviour, when nothing overlays the webview.
@GitToTheHub GitToTheHub changed the title fix(ios): display web view behind toolbar and address label and add custom toolbar background fix(ios): add custom toolbar background Mar 6, 2026
- On iOS 18 and older, an extra margin is not needed at top and bottom
- Apply a bottom margin for the toolbar only when it is at top
@GitToTheHub
Copy link
Contributor Author

I turned back to not overlay something over the webview, because i had scrolling issues with an iframe. Now it is like before, but the toolbar has a background which is equivalent on iOS 18 and 26.

@GitToTheHub GitToTheHub requested a review from dpogue March 6, 2026 17:29
- Instead of using a custom approach it's better to use the tools which should be used for auto layoit
- For margins use the `layoutMarginsGuide`
- For spacing use `constraintEqualToSystemSpacingBelowAnchor:`
@GitToTheHub
Copy link
Contributor Author

I updated the screenshots showing the auto layout margins and spacing and added screenshots when the toolbar is at top for iOS 18 and 26

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: Toolbar background transparent and not changeable since iOS 26 iOS26 Liquid Glass issue

3 participants