Ios 状态栏自定义

2018-09-13  本文已影响0人  宁静世界

修改状态背景颜色

func setStatusBarBackgroundColor(color :UIColor) {
      let statusBarWindow :UIView=UIApplication.shared.value(forKey:"statusBarWindow")as!UIView
      let statusBar :UIView = statusBarWindow.value(forKey:"statusBar")as!UIView
      if statusBar.responds(to:#selector(setter:UIView.backgroundColor)) {
//            statusBar.backgroundColor = color
          statusBar.tintColor = color
      }
      UINavigationBar.appearance().barTintColor = color
  }

修改状态文字颜色

  override var preferredStatusBarStyle: UIStatusBarStyle {
      return .lightContent
      
  }
上一篇 下一篇

猜你喜欢

热点阅读