Munir Xavier Wanis

SwiftUI status bar background color bug

Recently when I released Live Tracker app people started to report a bug about the status bar being all white.

Device bug example
Live Tracker status bar bug on iOS 13.2.3

The expected behaviour should be a red background color like the NavigationView, on iOS 13.5 it looked just fine but on previous versions it was acting buggy like that. So, to get it working as expected I had to use a ZStack to put a Color view ignoring the top safe area, the code is simple and will look like this:

struct ContentView: View {
    var body: some View {
        ZStack {
            Color.red.edgesIgnoringSafeArea(.top)

            NavigationView {
                Text("Hello World!")
            }
        }
    }
}

That's it! Now it should be showing the desired color on your status bar. It looks kinda hacky and although Apple fixed it on newer versions it's still necessary to use it on older versions.

Tagged with: