热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

SwiftUIAlterViewController2022年11月更新

importUIKitclassBusinessMainController:BaseTableViewController{overridefuncviewDidLoad(){s


import UIKitclass BusinessMainController: BaseTableViewController {override func viewDidLoad() {super.viewDidLoad()self.title = "业务类"//定义按钮,显示最简单的Alterlet button1 = UIButton(type: UIButton.ButtonType.system)button1.frame = CGRect(x: 30, y: 70, width: self.view.frame.size.width-60, height: 35)button1.setTitle("最简单的Alter", for: UIControl.State.normal)button1.addTarget(self, action: #selector(button1Action), for: UIControl.Event.touchUpInside)self.view .addSubview(button1)}@objc func button1Action() {let alterController = UIAlertController(title: "最简单的Alter", message: nil, preferredStyle: UIAlertController.Style.alert)let action1 = UIAlertAction(title: "星期一", style: UIAlertAction.Style.default) { (UIAlertAction) -> Void in}let action2 = UIAlertAction(title: "星期二", style: UIAlertAction.Style.destructive) { (UIAlertAction) -> Void in}let action3 = UIAlertAction(title: "星期三", style: UIAlertAction.Style.default) { (UIAlertAction) -> Void in}let action4 = UIAlertAction(title: "取消", style: UIAlertAction.Style.cancel) { (UIAlertAction) -> Void in}alterController.addAction(action1)alterController.addAction(action2)alterController.addAction(action3)alterController.addAction(action4)self.present(alterController, animated: true, completion: nil)}@objc func button2Action() {let alterController = UIAlertController(title: "带文本框的Alter", message: nil, preferredStyle: UIAlertController.Style.alert)alterController.addTextField { (textField: UITextField) -> Void intextField.placeholder = "请输入账号"}alterController.addTextField { (textField: UITextField) -> Void intextField.placeholder = "请输入密码"textField.isSecureTextEntry = true}let action = UIAlertAction(title: "登录", style: UIAlertAction.Style.cancel) { (UIAlertAction) -> Void in}alterController.addAction(action)self.present(alterController, animated: true) { () -> Void in}}@objc func button3Action() {let alterController = UIAlertController(title: "最简单的Alter", message: nil, preferredStyle: UIAlertController.Style.actionSheet)let action1 = UIAlertAction(title: "星期一", style: UIAlertAction.Style.default) { (UIAlertAction) -> Void in}let action2 = UIAlertAction(title: "星期二", style: UIAlertAction.Style.destructive) { (UIAlertAction) -> Void in}let action3 = UIAlertAction(title: "星期三", style: UIAlertAction.Style.default) { (UIAlertAction) -> Void in}let action4 = UIAlertAction(title: "取消", style: UIAlertAction.Style.cancel) { (UIAlertAction) -> Void in}alterController.addAction(action1)alterController.addAction(action2)alterController.addAction(action3)alterController.addAction(action4)self.present(alterController, animated: true, completion: nil)}}

这里写图片描述

这里写图片描述

这里写图片描述


推荐阅读
author-avatar
谁是我我2010
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有