SwiftUI: Status Bar Translucency

When working on an app, I encountered an issue when wrapping NavigationViews in a TabView. The navigation bar would show the proper translucency when other views were scrolled behind it, but the status bar had a black background, (white when in light mode), that I could not get rid of.

Before Code:

Before Simulator:

Before – iPhone

As you can see here, the black bar on the status bar is very annoying, and the fix is super simple. All you need to do is add the following line of code as a property of your TabView:

After Simulator:

After – iPhone

This allows your TabView, (and NavigationView by extension) to ignore the safe area allotted by Swift and carry the background theme up into the status bar. This is also a fix if you are struggling with editing the color of the NavigationView in your app delegate.

I hope someone can get some use from this!

After Code:

1 Reply to “SwiftUI: Status Bar Translucency”

Leave a Reply

Your email address will not be published. Required fields are marked *