前端之家收集整理的这篇文章主要介绍了
Swift NavigationController的使用,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
一、创建导航条
func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window?.backgroundColor = UIColor.whiteColor()
let firstVC = FirstViewController(nibName:nil,bundle: nil)
let navigation = UINavigationController(rootViewController: firstVC)
self.window?.rootViewController = navigation;
return true
}
二、导航条上添加按钮
let item = UIBarButtonItem(title: "下一个",style: UIBarButtonItemStyle.Plain,target: self,action: "buttonClick:")
self.navigationItem.rightBarButtonItem = item
三、跳转到下一个界面
func buttonClick(button:UIButton) {
let secondVC = SecondViewController(nibName:nil,bundle: nil)
self.navigationController?.pushViewController(secondVC,animated:true)
}
四、返回到上一个界面
func back() {
self.navigationController?.popViewControllerAnimated(true)
}
原文链接:https://www.f2er.com/swift/324153.html