美文网首页
iOS swift 设置导航栏背景颜色及标题字体

iOS swift 设置导航栏背景颜色及标题字体

作者: iOS_Developer | 来源:发表于2017-04-19 09:25 被阅读3233次

ContactsViewController是要设置的导航控制权UINavigationController的根控制器rootViewController,在viewDidLoad中添加以下代码,效果如下图

Snip20170419_1.png
import UIKit

class ContactsViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //导航栏
        self.title = "通讯录"
        
        navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white]
        
        navigationController?.navigationBar.barTintColor = UIColor(red: 66/256.0, green: 176/256.0, blue: 216/256.0, alpha: 1)
        
        navigationController?.navigationBar.isTranslucent = false
        

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

相关文章

网友评论

      本文标题:iOS swift 设置导航栏背景颜色及标题字体

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