1.新建一个消息弹窗方法,弹窗标题”错误!”,关闭弹窗按钮是“好的”
func showMsgbox(_message: String, _title: String = "错误!") {
let alert = UIAlertController(title: _title, message: _message, preferredStyle: UIAlertController.Style.alert)
let btnOK = UIAlertAction(title: "好的", style: .default, handler: nil)
alert.addAction(btnOK)
self.present(alert, animated: true, completion: nil)
}
2.调用自定义弹窗函数
showMsgbox(_message: "弹窗里要显示的内容")