Adaptation of iOS6 and iOS7 code (2) -- status bar

Source: Internet
Author: User

Run the application with Xcode5. The first result is the status bar change. In iOS6, the status bar is being processed by the system and does not need to be considered in the application. After iOS7, the application is processing. Each ViewController can control the status bar.

The status bar in iOS7 is transparent and will display the following content together. For example, my application colors are deep and I hope the icons on the status bar will be light. So I need to do two steps:

1. Set View controller-based status bar appearance to NO in info. plist.

2. In the AppDelegate. m file, add the didfinishlaunchingwitexceptions method.

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];    [[UIApplication sharedApplication] setStatusBarHidden:NO];

In this way, the status bar in the application is changed to a light color style.


If some viewController applications require special settings for the status bar, they need to be processed in the corresponding viewController. In this case, you need to rewrite two APIs, preferredStatusBarStyle and prefersStatusBarHidden.

-(UIStatusBarStyle)preferredStatusBarStyle{    return UIStatusBarStyleLightContent;}

- (BOOL)prefersStatusBarHidden{    return YES;}
Then, call [self setNeedsStatusBarAppearanceUpdate] to refresh the status bar style.

In iOS7, the status bar is floating on the upper layer, so that if the window itself moves down 20 pixel, it can be perfectly displayed. This method should be set up theoretically. I tried it but it was not successful. If it was successful, please tell me how to do it.


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.