美文网首页
通过Swift设置ios下NavigationBar颜色字体的方

通过Swift设置ios下NavigationBar颜色字体的方

作者: 6541f6a92920 | 来源:发表于2015-03-18 19:28 被阅读2943次
  • 设置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

相关文章

网友评论

      本文标题:通过Swift设置ios下NavigationBar颜色字体的方

      本文链接:https://www.haomeiwen.com/subject/bcqwxttx.html