关于 iOS 7 状态栏颜色和可见性的另一个问题......在我的解决方案中我想要拥有所有这些东西:
- 状态栏将在 View Controller 上隐藏和显示(带有动画),以响应用户操作(当用户滑动东西时)
- 当新的 View Controller 推送到导航 Controller 时,状态栏中文本的颜色应从黑色变为白色
- 当新的 View Controller 出现时,状态栏应该始终显示
我在使用“基于 View Controller 的状态栏外观”plist 设置时遇到问题;当否时,我可以显示和隐藏状态栏,但不能更改颜色;而当设置为 YES 时,反之亦然。
最佳答案
在 plist 中使用基于 View Controller 的状态栏外观为“否”,它可以工作。
例如->
可以说在 viewcontroller1
中,我有下面的代码
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear: animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}
我从 viewcontroller1
推送 viewcontroller2
,其代码如下
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear: animated];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}
使用上面的代码在模拟器中测试时,它完美地动画了这些变化。
关于ios - 在 iOS 中显示和隐藏状态栏+更改 View Controller 之间的状态栏文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21981766/