Xcode9学习笔记30
来源:互联网 发布:锤子科技 知乎 编辑:程序博客网 时间:2024/05/16 06:05
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let bt = UIButton(type: UIButtonType.system) bt.frame = CGRect(x: 20, y: 120, width: 280, height: 44) bt.setTitle("Question", for: UIControlState()) bt.addTarget(self, action: #selector(ViewController.showAlert), for: .touchUpInside) bt.backgroundColor = UIColor.lightGray self.view.addSubview(bt) } @objc func showAlert() { let alert = UIAlertController(title: "Information", message: "Are you happy?", preferredStyle: UIAlertControllerStyle.alert)//初始化一个警告窗口,并设置窗口的标题文字和提示信息 let yes = UIAlertAction(title: "Yes", style: UIAlertActionStyle.default) { (alerts: UIAlertAction) in print("Yes, I am happy.") } let no = UIAlertAction(title: "No", style: UIAlertActionStyle.default) { (alerts: UIAlertAction) in print("No, I am not happy.") } alert.addAction(yes) alert.addAction(no) self.present(alert, animated: true, completion: nil) }
阅读全文
0 0
- Xcode9学习笔记30
- Xcode9学习笔记1
- Xcode9学习笔记2
- Xcode9学习笔记3
- Xcode9学习笔记4
- Xcode9学习笔记5
- Xcode9学习笔记6
- Xcode9学习笔记7
- Xcode9学习笔记8
- Xcode9学习笔记9
- Xcode9学习笔记10
- Xcode9学习笔记11
- Xcode9学习笔记12
- Xcode9学习笔记13
- Xcode9学习笔记14
- Xcode9学习笔记15
- Xcode9学习笔记16
- Xcode9学习笔记17
- 「C语言精髓_高级数据表示」抽象数据类型(ADT)
- STL及各种技巧
- 【09】框架学习—Spring的IoC容器之XML方式
- IIS 注册 .net
- kafka 0.8 simple api使用
- Xcode9学习笔记30
- 合并两个单链表算法
- Python-简单网络抓取
- 关于穿梭时空
- Xcode9学习笔记31
- 和学生们的合影-20171104-gaojj-zhangsc-dengxy-suhw-xuyc
- 坚持#第234天~零基础自学云计算基础语言应用之python第10节(最后一节啦)
- 51nod 1323 完美平方 线性基+bitset+数学
- 当python找不到pip的时候