How can I change the statusbar background color to a different color. I am using a NavigationView and ZStack.
I want the white area above the green Navigationbar to be green for example. How can I change that?
What I tried
Here is my code for the NavigationBar:
init() {
UINavigationBar.appearance().largeTitleTextAttributes = [
.foregroundColor : UIColor(#colorLiteral(red: 0.8745098039, green: 0.3411764706, blue: 0, alpha: 1))]
UINavigationBar.appearance().backgroundColor = UIColor(named: "backgroundColor")
}
Here is my code for the background color of the app:
var body: some View {
NavigationView {
ZStack {
Color("backgroundColor")
.edgesIgnoringSafeArea(.all)
}
.navigationBarTitle(Text("Agenda"))
}
}
}
And last but not least my scene delegate code:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let newAppearance = UINavigationBarAppearance()
newAppearance.configureWithOpaqueBackground()
newAppearance.backgroundColor = .black
newAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().standardAppearance = newAppearance
//Other code for displaying the first screen
}