Swift--UINavigationController
来源:互联网 发布:怎样延长淘宝收货时间 编辑:程序博客网 时间:2024/06/10 01:53
代码目录
AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. self.window = UIWindow(frame: UIScreen.mainScreen().bounds); self.window?.backgroundColor = UIColor.whiteColor(); self.window?.makeKeyAndVisible(); let main = ViewController(); let nvc = UINavigationController(rootViewController: main); self.window?.rootViewController = nvc; return true }
ViewController.swift
class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.title = "Main"; let nextItem = UIBarButtonItem(title: "Next", style: UIBarButtonItemStyle.Plain, target: self, action: "next"); self.navigationItem.rightBarButtonItem = nextItem; } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func next(){ let next = Next(); self.navigationController?.pushViewController(next, animated: true); }}
Next.swift
class Next: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.title = "Next" let btn = UIButton(frame: CGRect(x: 110, y: 100, width: 100, height: 40)); btn.setTitle("Back", forState: .Normal) btn.addTarget(self, action: "butClick", forControlEvents: .TouchUpInside) btn.backgroundColor = UIColor.blueColor(); self.view.addSubview(btn) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } func butClick() { self.navigationController?.popViewControllerAnimated(true); }}
效果图
0 0
- Swift--UINavigationController
- swift UINavigationController 导航控制器
- swift UINavigationController属性设置
- Swift基础(三十一)UINavigationController
- swift 3.0 -UINavigationController
- swift中UINavigationController的使用
- swift uinavigationController 视图控制器切换(二)
- Swift 中UIWebView 和 UINavigationController的应用
- [赵三哥Swift学习笔记]UINavigationController
- Swift 开发:UINavigationController和UITabBarController用法案例
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- UINavigationController
- Android Studio配置问题
- eclipse环境搭建之五:Scala
- UIView 实现渐变色 CAGradientLayer
- 【NOIP2012提高组】国王游戏
- 利用java实现简单租车系统(控制台程序版)
- Swift--UINavigationController
- tcp简单传输过程分析
- EM算法
- Spark RDD 的创建 & Accumulators
- MyBatis官方教程及源码解析——类型别名、类型处理器的解析
- CAS——概述
- 【C/C++】Linux下使用system()函数一定要谨慎
- Eclipse工具栏上android的机器人小图标和adt图片的显示
- 后缀数组 Poj---1743 : Musical Theme