swift navigation title 标题颜色代码设置

2018-03-13  本文已影响54人  做人要简单

简单记录,为后续方便查找,仅有代码片段
可以放在ViewController的基类中

if let bar = self.navigationController?.navigationBar {
            bar.backgroundColor = .themeColor
            bar.tintColor = .white
            var attrs = bar.titleTextAttributes
            if attrs == nil {
                attrs = [NSAttributedStringKey:Any]()
            }
            attrs?[NSAttributedStringKey.foregroundColor] = UIColor.white
            bar.titleTextAttributes = attrs
        }
上一篇 下一篇

猜你喜欢

热点阅读