How would I create a UIAlertView in Swift?

let Msg:String = "Hello"
 
 let alert = UIAlertController(title: "Alert", message: Msg, preferredStyle: UIAlertControllerStyle.alert)
 
 alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { action in
 
 switch action.style{
 
 case .default:
 
 print("default")
 
 case .cancel:
 
 print("cancel")
 
 case .destructive:
 
 print("destructive")
 
 }}))
 
 self.present(alert, animated: true, completion: nil)

 

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *