美文网首页
状态栏颜色修改

状态栏颜色修改

作者: 天顾有情人_strive | 来源:发表于2017-07-14 15:31 被阅读3次

//设置状态栏颜色

- (void)setStatusBarBackgroundColor:(UIColor *)color {

UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]){

statusBar.backgroundColor = color;

}

}

然后调用

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

[self setStatusBarBackgroundColor:[UIColor redColor]];

}

本来是透明的,就会变成红色。

相关文章

网友评论

      本文标题:状态栏颜色修改

      本文链接:https://www.haomeiwen.com/subject/ruxohxtx.html