1.UINavigationController的创建
let nvc:UINavigationController = UINavigationController(rootViewController: vc)
2.导航栏的设置
//获取全局的navgationBar
var navgationBar:UINavigationBar = UINavigationBar.appearance()
//设置导航栏的上渲染颜色 包含字体颜色和返回按钮的箭头颜色
navgationBar.tintColor = UIColor.whiteColor()
//设置导航栏的背景颜色
navgationBar.barTintColor = UIColor.redColor()
//设置导航栏的样式
navgationBar.barStyle = UIBarStyle.BlackTranslucent
3.设置导航标题
self.navigationItem.title = "swift导航"
也可以通过设置
4.navigationItem的设置
var barItem:UIBarButtonItem = UIBarButtonItem(title: "下一页", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("pushNextController"))
//右侧按钮
self.navigationItem.rightBarButtonItem = barItem
关于返回按钮 推荐大家使用系统的,可以通过设置
navgationBar.
tintColor来改变为自己想要的颜色
5.push 和 pop
//push一个ViewController
let nextVC:KYNextViewController = KYNextViewController()
self.navigationController!.pushViewController(nextVC, animated: true)
//pop回一个ViewController
self.navigationController?.popViewControllerAnimated(true)