話不多,直接貼代碼:
?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)// 設置背景顏色
?
?