UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Set .toolbarColorScheme to white with a transparent background in SwiftUI

Forums > SwiftUI

In SwiftUI I need to make the statusbar content (time, battery) white without any background color, only the image I specified for the view is behind it. The ideal way would be to use .toolbarColorScheme and do this:

.toolbarColorScheme(.dark, for: .navigationBar) .toolbarBackground(Color.white.opacity(0), for: .navigationBar) .toolbarBackground(.hidden, for: .navigationBar)

However, .toolbarColorScheme with a .dark value always automatically has a dark colored material background and can't be used without it. Is there any way to still use it and remove the dark background? (for instance with introspect)

After trying many different other ways, none of them worked without breaking something else. I also can't use .preferredColorScheme because then I can't make the smooth transitions work between the main view where the statusbar content needs to be dark and the detail view where the statusbar content needs to be white.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.