/** Title Text Attribute title文字的大小和颜色 */
private static var defaultTitleTextAttribute: [String : AnyObject]? {
let font = UIFont.boldSystemFontOfSize(18)
let textColor = UIColor(hexString: "#FFFFFF")!
return [NSFontAttributeName: font, NSForegroundColorAttributeName: textColor]
}
1 // navigationBar 返回按钮颜色
2 self.tintColor = UIColor.redColor()
3 // navigationBar 的颜色
4 self.barTintColor = UIColor.yellowColor()
5 // navigationBar上title 文字的大小颜色等
6 self.titleTextAttributes = UINavigationBar.defaultTitleTextAttribute
// 7 8 9 行设置navigationBar 为透明的
7 self.translucent = true
8 self.shadowImage = UIImage()
9 self.setBackgroundImage(UIImage(), forBarMetrics: .Default)
// 自定义navigationleftBarButtonItem 返回按钮
if let viewControllers = self.navigationController?.viewControllers where viewControllers.count > 1 {
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "NavigationBar_Back"), style: .Plain, target: self, action: #selector(backBarButtonItemClicked))
}
func backBarButtonItemClicked() {
self.navigationController?.popViewControllerAnimated(true)
}