Xcode9学习笔记31
来源:互联网 发布:锤子科技 知乎 编辑:程序博客网 时间:2024/05/16 01:15
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.showActionSheet), for: .touchUpInside) bt.backgroundColor = UIColor.lightGray self.view.addSubview(bt) } @objc func showActionSheet() { let alert = UIAlertController(title: "Information", message: "What's your favorite", preferredStyle: UIAlertControllerStyle.actionSheet)//设置弹出窗口样式为动作表 let fishing = UIAlertAction(title: "Fishing", style: UIAlertActionStyle.default) { (alerts: UIAlertAction) in print("I like fishing")//默认样式的按钮 } let hunting = UIAlertAction(title: "Hunting", style: UIAlertActionStyle.destructive) { (alerts: UIAlertAction) in print("I like hunting")//消除样式的按钮 } let nothing = UIAlertAction(title: "Nothing", style: UIAlertActionStyle.cancel) { (alerts: UIAlertAction) in print("I like nothing")//取消样式的按钮 } alert.addAction(fishing) alert.addAction(hunting) alert.addAction(nothing) self.present(alert, animated: true, completion: nil) }
阅读全文
0 0
- Xcode9学习笔记31
- 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
- kafka 0.8 simple api使用
- Xcode9学习笔记30
- 合并两个单链表算法
- Python-简单网络抓取
- 关于穿梭时空
- Xcode9学习笔记31
- 和学生们的合影-20171104-gaojj-zhangsc-dengxy-suhw-xuyc
- 坚持#第234天~零基础自学云计算基础语言应用之python第10节(最后一节啦)
- 51nod 1323 完美平方 线性基+bitset+数学
- 当python找不到pip的时候
- 【笔记+模板】 匈牙利算法
- Luogu P1434 滑雪
- MNIST For ML Beginners
- 每日一练_04