Question:
My application has a dark background, but in iOS 7 the status bar became transparent. So I can’t see anything there, only the green battery indicator in the corner. How can I change the status bar text color to white like it is on the home screen?Best Answer:
Set the
UIViewControllerBasedStatusBarAppearance
toYES
in the .plist file.In the
viewDidLoad
do a[self setNeedsStatusBarAppearanceUpdate];
Add the following method:
- (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
Note: This does not work for controllers inside
UINavigationController
, please see Tyson’s comment below 🙂 Swift 3 – This will work controllers inside
UINavigationController
. Add this code inside your controller.For SwiftUI create a new swift file called
HostingController.swift
SceneDelegate.swift
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review