swift - 导航栏设置

话不多,直接贴代码:

let nav = UINavigationController.init(rootViewController: viewController)

nav.topViewController?.title = title// 设置导航栏的标题

nav.navigationBar.tintColor = .whiteColor()// 设置push出的导航栏的返回颜色(箭头及文字)

UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]// 设置标题颜色

UINavigationBar.appearance().barTintColor = UIColor(hexString: mainColorHexString)// 设置背景颜色