Where is the correct place to write the code for Status Bar, and How can to change the Status Bar light or dark in SwiftUI?
Related
I usually use this trick to change the status bar text color with SwiftUI. But since iOS 15, the status bar color text is automatically set to black when I present a view with .fullScreenCover and I can't change its color. However, I still can change status bar text color on a navigation view.
Is there another way to change the status bar text color on View presented by .fullScreenCover on iOS15 ?
XCode Version: 13.0 (13A233)
iOS Version: 15.0
Looking to change the status bar text colour (on a per view basis) using swiftui but cannot seem to do it?
I can change it for the whole app but some screens have a different status bar colour so the text needs to switch from black to white when the background is dark?
Any ideas on how to achieve this?
I am making a dark theme for my app, where all the background is black and text and controls are orange. I also want the status bar to correspond to this theme, but .lightContent option, which is designed for dark backgrounds, returns white text color. I was wondering if it's at all possible to make status bar text something other than black or white (orange, in my case)?
It is not possible to change the status bar's text color as the apple provided only two colors for displaying status bar text which is white and black.
To display white text add the following stuff to your project Info.plist
View controller-based status bar appearance = false
Status bar style = Transparent black style (alpha of 0.5)
To display black text add the following stuff to your project Info.plist
View controller-based status bar appearance = false
Status bar style = Gray style (default) OR Opaque black style
The navigation bar is setting the color of the status bar to black, unless I change its barStyle to .blackTranslucent. When that's set, the status bar text is white, which is what I want, but the border on the bottom of the navigation bar becomes translucent as well, and I would like for that to be visible. Here's what I mean:
when nav_bar.barStyle = .default:
when nav_bar.barStyle = .blackTranslucent:
Is there any way to get the best of both worlds, where I could have white status bar text as well as a visible navigation bar border? Thanks!
The solution is to set View controller-based status bar appearance in info.plist to NO.
I'm using a light colored status bar UIStatusBarStyleLightContent and my subclassed navigation bars use a dark color set using the appearance API.
When a private modal view is presented such as "Printer Options" from a UIActivityViewController the status bar color stays light so it's not readable with the default navigation bar color.
How do you tell these view controllers to change to a dark status bar color when presented?