- 需要将根视图改为navigation controller控制
- 在AppDelegate添加如下代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//.导航栏
let navBar=UINavigationBar.appearance()
//.设置导航栏标题颜色
navBar.titleTextAttributes = [ NSForegroundColorAttributeName : UIColor.whiteColor()]
//.设置导航栏按钮颜色
navBar.tintColor = UIColor.whiteColor()
//.设置导航栏背景颜色
navBar.barTintColor=UIColor(red: 49.0/255.0, green: 183.0/255.0, blue: 235.0/255.0, alpha: 1.0)
//.状态栏文字白色风格
UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
return true
}
3.修改添加info.plist文件
添加View controller-based status bar appearance,设置为no,默认没有是yes