未分類

アラートを表示する

投稿日:

アラートを表示するメソッド

//アラート
    func displayAleart() {
        let alert: UIAlertController = UIAlertController(title: "アラート表示", message: "保存してもいいですか?", preferredStyle:  UIAlertController.Style.alert)

        let defaultAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler:{
            (action: UIAlertAction!) -> Void in
            print("OK")
        })
        let cancelAction: UIAlertAction = UIAlertAction(title: "キャンセル", style: UIAlertAction.Style.cancel, handler:{
            (action: UIAlertAction!) -> Void in
            print("Cancel")
        })

        alert.addAction(cancelAction)
        alert.addAction(defaultAction)

        present(alert, animated: true, completion: nil)
    }

参考:【Swift】アラートを表示する(Alert/ActionSheet)

-未分類

執筆者:

関連記事

no image

PremiereProのテキストアニメーション簡単なやつ色々

・ぼかしからぼやっと出てくる エフェクト「ブラー(ガウス)」→開始でブラー値300、10フレーム後で0 参考:https://youtu.be/pamD-YrZGuY   ・1文字ずつ出てる …

レガシータイトルで綺麗な角丸四角形を作る方法

レガシータイトルで綺麗な角丸四角形を作りたい。 角丸長方形(可変)ツールで作ると角が歪む 角丸長方形を作成し、右の「フィレットサイズ」で角を調整できる。 ただし、角が歪んでしまう。(画像の下の長方形の …

no image

画面遷移する時に値を渡す

1.遷移先で値を受け取るための変数を宣言しておく。 class NextViewController: UIViewController { @IBOutlet weak var label2: UI …

no image

collectionViewの基本的な使い方

1.collectionViewを画面一杯に配置する。CellのIdentifierに任意の名前「Cell」とつける。 2.プロトコルを追加し、デリゲートの設定をする。 class ViewContr …

no image

TableViewとは

TableViewとはリスト型のパーツである。 TableViewを構築するときに必要なメソッド ・セルの数を決めるメソッド ・セルのセクション数を決めるメソッド ・セルを構築する際に呼ばれるメソッド …