LoginSignup
20
15

More than 5 years have passed since last update.

swiftでアクションシートを使う

Posted at

アクションシートとはぴょこっと出てくるあれです。

これ
スクリーンショット 2016-06-25 10.36.08.png

追加方法

以下をコピペでボタンアクションのところとかにコピペすればokです。

        // styleをActionSheetに設定
        let alertSheet = UIAlertController(title: "title", message: "message", preferredStyle: UIAlertControllerStyle.ActionSheet)

        // 自分の選択肢を生成
        let action1 = UIAlertAction(title: "1", style: UIAlertActionStyle.Default, handler: {
            (action: UIAlertAction!) in
        })
        let action2 = UIAlertAction(title: "aka", style: UIAlertActionStyle.Destructive, handler: {
            (action: UIAlertAction!) in
        })
        let action3 = UIAlertAction(title: "cancel", style: UIAlertActionStyle.Cancel, handler: {
            (action: UIAlertAction!) in
        })

        // アクションを追加.
        alertSheet.addAction(action1)
        alertSheet.addAction(action2)
        alertSheet.addAction(action3)

        self.presentViewController(alertSheet, animated: true, completion: nil)
20
15
1

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
20
15