About changing the status bar color after ios7
Once I see it on the Internet, I want to set it after ios7.
First, add the key UIViewControllerBasedStatusBarAppearance In the Info. plist configuration file and set it to YES;
Then, implement the following two methods in the UIViewController subclass:
-(UIStatusBarStyle) preferredStatusBarStyle {return UIStatusBarStyleLightContent;}-(BOOL) prefersStatusBarHidden {return NO;} Finally, call the [self-reported] method to refresh the status bar style:
[Self setNeedsStatusBarAppearanceUpdate] a call in the push or present controller takes effect.
The strange thing is that after I set it like this, only after logging on to the logon interface with a helpful interface (it should be correct that the color of the status bar turns black after the network request data is not redirected yet, in addition, it is useless to set the settings on the next interface. Maybe it is because my login interface is present or why, so I will not discuss it first.) the color will change back. I don't know if there is a problem with this method, or is there a problem with my code.
Then I found a one available in my project. Slightly changed, because I just entered the interface will have a full screen image.
Call setStatusBarStyle. Any iOS version is available in the plist file.
Code
if (IsIOS7Later) { [[UIApplication sharedApplication] setStatusBarHidden:NO]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; }
In addition, I also found that there is no status bar in the logon interface under ios6.0 .. (The logon interface is not navg ).
If (! IsIOS7Later ){
[UIApplicationsharedApplication]. statusBarHidden = NO;
}
...
Why?
- (UIStatusBarStyle)preferredStatusBarStyle
This method won't work on another interface. I guess it's my code problem.