IOS changes the color of the top battery bar in real time
The statusBarStyle (battery bar) color on the top is modified in real time based on the offset on the sliding interface. Directly run the Code:
First, set the View controller-based status bar appearance parameter in the info. plist file to NO.
Set the style in the proxy method of scrollView.
-(Void) scrollViewDidScroll :( UIScrollView *) scrollView
{
_ Content = scrollView. contentOffset. y;
_ Navview. alpha = _ content/200;
If (_ navview. alpha> 0 ){
Return [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: NO]; // black
}
Return [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleLightContent animated: NO]; // white
}
Note that if you do not need to change the battery color on the previous interface or the next interface, you need to set the battery color to the original color in the previous interface and the viewWillAppear method on the next interface.
-(Void) viewWillAppear :( BOOL) animated
{
[Super viewWillAppear: animated];
// Set the battery to black.
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: NO];
}