1 2 3 4 5 6 7 |
@IBAction func onTap(_ sender: UIButton) { let alertController = UIAlertController(title: "title", message: "message", preferredStyle: .actionSheet) alertController.addAction(UIAlertAction(title: "キャンセル", style: .default, handler: nil)) alertController.addAction(UIAlertAction(title: "アクション1", style: .default, handler: {action in sender.setTitle("1を選択", for: .normal)})) alertController.addAction(UIAlertAction(title: "アクション2", style: .default, handler: {action in sender.setTitle("2を選択", for: .normal)})) present(alertController, animated: true, completion: nil) } |