swift修改导航栏和状态栏颜色
2017-08-01 本文已影响0人
雪鹰_007
修改导航栏颜色
self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController!.navigationBar.shadowImage=UIImage()
self.navigationController?.navigationBar.backgroundColor = UIColor.colorWithHexString(hex:"#37363c")
修改状态栏颜色
///设置状态栏背景颜色
funcsetStatusBarBackgroundColor(color :UIColor) {
letstatusBarWindow :UIView=UIApplication.shared.value(forKey:"statusBarWindow")as!UIView
letstatusBar :UIView= statusBarWindow.value(forKey:"statusBar")as!UIView
ifstatusBar.responds(to:#selector(setter:UIView.backgroundColor)) {
statusBar.backgroundColor= color
}
UINavigationBar.appearance().barTintColor= color
}