IOS7 StatusBar Use Summary

Source: Internet
Author: User

    • 1. Style
    • 2. Show and Hide
    • 3. Animation effect
    • 4. Default No StatusBar
    • Other

The StatusBar in iOS7 has changed significantly compared to previous versions, and the use of StatusBar in iOS7 requires a new approach, and now summarizes the following StatusBar methods:

    • Style
    • Show and Hide
    • Animation effects
    • Default No StatusBar
1. Style

There are two styles of StatusBar:

    • Uistatusbarstyledefault:

    • Uistatusbarstylelightcontent

To change the display style of the statusbar, you need to overload it in Uiviewcontroller:

?
1234 - (UIStatusBarStyle)preferredStatusBarStyle{    returnUIStatusBarStyleLightContent;}



This method cannot be called directly, and is called where the style needs to be changed: [Self setneedsstatusbarappearanceupdate]

Example:

?
1234 - (void)viewWillAppear:(BOOL)animated{    [self setNeedsStatusBarAppearanceUpdate];}



2. Show and Hide

Show and hide StatusBar as long as it is overloaded in Uiviewcontroller:

?
1234 - (BOOL)prefersStatusBarHidden{    returnYES;}



The same type of change requires the [self setneedsstatusbarappearanceupdate] method to be called

3. Animation effect

Now there are two kinds of animation effects: Uistatusbaranimationfade, uistatusbaranimationslide. From their name can be learned what his specific eye effect. Implementing animations requires overloading:

?
1234 - (UIStatusBarAnimation )preferredStatusBarUpdateAnimation{    returnUIStatusBarAnimationSlide;}



However, after overloading this method, there is no animation effect. At this point, we need to put [self setneedsstatusbarappearanceupdate] in the animation block execution:

?
1234 [UIView animateWithDuration:0.3                 animations:^{                    [self setNeedsStatusBarAppearanceUpdate];}];



So the animation effect appears.

4. Default No StatusBar

There are some applications that are not StatusBar by default:

Such an application is ugly, always feel the shortcomings of what, but some product managers are like.

To achieve this effect, you need to always set the status bar is initially hidden field to YES in the project configuration plist file, add the view controller-based status bar appearance field, and set the value To NO:

Other

There are some decency to provide the build, such as sending mail mfmailcomposeviewcontroller, cannot change the Statabar style, is to use its subclasses can not be implemented, if a friend knows how to achieve, be sure to tell the younger brother, greatly appreciated

IOS7 StatusBar Use Summary

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.