ios

list of alert button style (default, cancel, destructive)

boywin1992 2022. 6. 14. 18:18
728x90

let alertTitleStr = "alert title"

let alertMessageStr = "alert message"

let actionStr = "action"

let cancelStr = "cancel"

let destructiveStr = "destructive"

 

let alert = UIAlertController(title: alertTitleStr, message: alertMessageStr, preferredStyle: .alert)

alert.addAction(UIAlertAction(title: actionStr, style: .default, handler: { UIAlertAction in

    print(actionStr)

}))

alert.addAction(UIAlertAction(title: cancelStr, style: .cancel, handler: { UIAlertAction in

    print(cancelStr)

}))

alert.addAction(UIAlertAction(title: destructiveStr, style: .destructive, handler: { UIAlertAction in

    print(destructiveStr)

}))

self.present(alert, animated: true)

728x90