我想改变StatusBarStyle,正在使用preferredStatusBarStyle方法,还添加了“基于视图控制器的状态栏外观”是是在plist,但我不知道,为什么不工作?我已提到以下步骤:
步骤:1
// preferredStatusBarStyle Method
-(UIStatusBarStyle)preferredStatusBarStyle
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat SW = screenRect.size.width;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
UIView *statusView=[[UIView alloc]initWithFrame:CGRectMake(0, 0,SW,20)];
statusView.backgroundColor=[UIColor blackColor];
[self.view addSubview:statusView];
return UIStatusBarStyleLightContent;
}步骤:2
//添加plist
基于视图控制器的状态栏appearance=“是”
步骤:3
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self preferredStatusBarStyle];
}请给我建议。
发布于 2015-06-15 11:48:02
没有直接更改状态栏颜色的方法。我们可以使用“setStatusBarStyle”属性选择状态栏样式,并在以下三种可用样式中进行选择:
UIStatusBarStyleDefault
UIStatusBarStyleBlackTranslucent
UIStatusBarStyleBlackOpaque然而,如果你想改变状态栏的颜色,有一个技巧可以做同样的-
更改UIWindow对象的背景色。并将状态栏样式设置为“UIStatusBarStyleBlackTranslucent”。这将设置状态栏的颜色与窗口的背景色相同。
将以下代码添加到applicationDidFinishLaunchingWithOptions中的AppDeligate.m文件中-
self.window.backgroundColor = [UIColor colorWithRed:0.78f green:0.13f blue:0.11f alpha:1];
[application setStatusBarStyle:UIStatusBarStyleBlackTranslucent];或者查看下面的教程,以自定义状态栏阿普科达
https://stackoverflow.com/questions/30843547
复制相似问题