- 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:
- 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