标签:
通过滑动界面,根据偏移量 实时修改顶部statusBarStyle(电池条)颜色。 直接上代码:
首先将info.plist文件中View controller-based status bar appearance这个参数设置为NO。
其次在scrollView的代理方法里设置样式即可
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
_content = scrollView.contentOffset.y;
_navview.alpha = _content / 200;
if (_navview.alpha > 0) {
return [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];//黑色
}
return [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];//白色
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//设置电池条为黑色
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];
}
标签:
原文地址:http://blog.csdn.net/liuxu0718/article/details/46049229