iOS状态栏颜色修改

1.此方法是设置状态栏整个背景颜色
- (void)setStatusBarBackgroundColor:(UIColor *)color
{
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = color;
    }
}

2.此方法可以直接设置状态栏文字白色
OC
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
Swift
override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
}

extension UINavigationController {
    open override var childViewControllerForStatusBarStyle: UIViewController? {
        return topViewController
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 本文直接开干性,需要知道的原理的简书很多文章都写的很详细,自行搜索。 一、iOS9 以前只需要设置 step1.修...
    lym不解释阅读 512评论 0 1
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 179,189评论 25 708
  • 前言 首先请大家看几张图: 以上的效果,一般我们统称为沉浸式状态栏。其实,这种叫法不是很准确,而且也没有沉浸式状态...
    宇是我阅读 4,199评论 2 28
  • 英雄魂 徐家兴 和往常一样 伴着紧急的铃声 她精神抖擞地来到教室 教室里一双双眼睛和往常一样 齐刷刷的向她投来 和...
    赤脚老怪阅读 292评论 2 4
  • today is a sunny day and the air you touch is not so clea...
    sen伊_阅读 328评论 1 0

友情链接更多精彩内容