设置导航栏颜色, 字体大小

取出导航栏

let bar = UINavigationBar.appearance()

设置导航栏背景色

bar.barTintColor = .white

设置标题颜色和字体大小

bar.titleTextAttributes = [NSAttributedString.Key.font:UIFont.boldSystemFontOfSize(18),NSAttributedString.Key.foregroundColor:UIColor.whiteColor()]

设置布局从导航栏下开始, 把导航栏设置为不透明

bar.isTranslucent = false
bar.shadowImage = UIImage()

设置状态栏的字体和图标的颜色为白色

UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)

当然,如果要更改状态栏的系统默认设置,就要先获取修改的权限,方法就是在plist文件里面添加一行设置:View controller-based status bar appearance设为NO,默认是YES。

这里即完成了以上一系列的设置,如果有特定的视图需要单独显示某种颜色,则可以在其viewWillAppear和viewWillDisappear方法里面单独设置和恢复设置一下即可。

请关注我的专题 iOS - Developer - Swift进阶大全

你可能感兴趣的:(设置导航栏颜色, 字体大小)