About changing the status bar color after ios7

Source: Internet
Author: User

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.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.