let controller = UIAlertController(title: "标题", message: "消息", preferredStyle: .alert)
controller.addTextField { textField in
textField.placeholder = "输入信息"
}
controller.addAction(UIAlertAction(title: "确认", style: .default, handler: { _ in
guard let text = controller.textFields?.first?.text else {
return
}
print("输入的信息为 \(text)")
}))
controller.addAction(UIAlertAction(title: "取消", style: .cancel, handler: { _ in }))
let rootView = UIApplication.shared.windows.first?.rootViewController
rootView?.present(controller, animated: true, completion: {})
iOS系统原生提供的输入确认框
最新推荐文章于 2022-04-26 07:44:52 发布