【swift】アラート(Alert) / アクションシート(ActionSheet)

アラート と アクションシート

    let alert: UIAlertController = UIAlertController(title: "アラート", message: "アラート", preferredStyle:  UIAlertControllerStyle.alert)

UIAlertControllerStyle.alert(アラート)or UIAlertControllerStyle.actionSheet(アクションシート)

    let action01: UIAlertAction = UIAlertAction(title: "action01", style: UIAlertActionStyle.default, handler:{
(action: UIAlertAction!) -> Void in
print("action01")
})
let action02: UIAlertAction = UIAlertAction(title: "action02", style: UIAlertActionStyle.default, handler:{
(action: UIAlertAction!) -> Void in
print("action02")
})
let actionCancel: UIAlertAction = UIAlertAction(title: "cancel", style: UIAlertActionStyle.cancel, handler:{
(action: UIAlertAction!) -> Void in
print("actionCancel")
})
alert.addAction(action01)
alert.addAction(action02)
alert.addAction(actionCancel)
present(alert, animated: true, completion: nil)

アクションシートは、UIAlertActionStyle.destructive (赤文字)も選べる。

返信を残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA