1
5

More than 5 years have passed since last update.

アクションシートを表示する

Posted at

スクリーンショット 2019-05-24 14.28.42.png:point_right_tone1: スクリーンショット 2019-05-24 14.28.56.png

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    @IBAction func tapAlert(_ sender: Any) {
        //アクションシートを作る
        let alert = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .actionSheet)

        //ボタン1
        alert.addAction(UIAlertAction(title: "追加する", style: .default, handler: nil))

        //ボタン2
        alert.addAction(UIAlertAction(title: "さらに追加する", style: .default, handler: nil))

        //消去する
        alert.addAction(UIAlertAction(title: "消去する", style: .destructive, handler: nil))

        //ボタン3
        alert.addAction(UIAlertAction(title: "キャンセル", style: .cancel, handler: nil))

        //アクションシートを表示する
        self.present(alert, animated: true, completion: nil)

    }


}

以上です。

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5