首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

IOS移动开发从入门到精通 视图UIView、层CALayer(2)

或者修改 rootViewController参数 2、弹出框: import UIKit class ViewController:UIViewController { var label:UILabel! override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = UIColor.brown label = UILabel(frame:CGRect(x:40, y:100,width:240, height:44)) label.text = ”” self.view.addSubview(label) let button = UIButton(frame:CGRect(x:40, y:180,width:240, height:44)) button.setTitle(“打开新的视图控制器”, for:UIControlState()) button.backgroundColor = UIColor.black button.addTarget(self, action:#selector(ViewController.openViewController),fo:.touchUpInside) self.view.addSubview(button) } func openViewController() { let newViewController = NewViewController() newViewController.labelTxt = “传递的参数!” newViewController.viewController = self self.present(newViewController, animated:true,completion:nil) } }

01

iOS中storyboard故事板使用Segue跳转界面、传值

在iOS的开发过程中,不可避免的要设计界面,在android中有xml设置界面和直接使用java代码设置界面控件两种方式,在之前的ios开发中也是类似的有xib文件设置界面及用代码直接设置控件两种方法,但后来又出了一种方式,就是storyboard故事板子,其实storyboard和xib文件很像,最大的不同之处在于一个xib文件对应一个ViewController视图控制器,而storyboard对应多个,基本一个应用只需要一个storyboard就可以了,不再需要为每个控制器创建一个xib文件,从这点上来说,还是很方便的,在storyboard中查看各个界面的跳转也很方便,但之前一直使用xib进行开发,对storyboard的使用不太熟悉,今天好好学习了一下其中的界面跳转和传值,用到了Segue这个东西,这里借着例子说明一下。

02

IOS移动开发从入门到精通

1 应用程序的5个阶段,放在 AppDelegate.swift application:didFinishLaunchingWithOptions 当应用程序载入后执行该方法。 ●applicationWillResignActive 当程序将要进入非活动状态时,调用此方法,在此期间,程序不接收消息或事件。 ●applicationDidEnterBackground 当程序被推送到后台的时候,调用此方法。如果要设置当程序进入后台仍然继续某些动作时,在这个方法里面添加代码即可。 ●applicationWillEnterForeground 当程序将要从后台重新回到前台的时候,调用此方法。 ●applicationDidBecomeActive 当程序进入活动状态的时候,执行该方法。 ●applicationWillTerminate 当程序将要退出时,将调用该方法。通常是用来保存数据和进行一些退出前的清理工作。

02
领券