ContactsViewController是要设置的导航控制权UINavigationController的根控制器rootViewController,在viewDidLoad中添加以下代码,效果如下图
Snip20170419_1.pngimport 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.
}
*/
}
网友评论