通过Swift设置ios下NavigationBar颜色字体的方
2015-03-18 本文已影响2943人
6541f6a92920
- 设置UINavigationBar背景颜色
UINavigationBar.appearance().barTintColor = UIColor(red: 36.0/255.0, green: 190.0/255.0, blue: 139.0/255.0, alpha: 1.0) - 设置UINavigationBar文本颜色
var attr: NSMutableDictionary! = [NSForegroundColorAttributeName: UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)] - 设置UINavigationBar字体
attr.setValue(UIFont(name: "AmericanTypewriter", size: 16.0), forKey: NSFontAttributeName) - 设置UINavigationBar文本阴影
var shadow = NSShadow()
shadow.shadowColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
shadow.shadowOffset = CGSizeMake(0, 1)
attr.setValue(shadow, forKey: NSShadowAttributeName)
UINavigationBar.appearance().titleTextAttributes = attr