LoginSignup
1
1

More than 1 year has passed since last update.

【Swift】アラートのテンプレート

Posted at

テンプレート

struct AlertUtils {
    private static var alertController = UIAlertController()

    static func alert(title: String, message: String, view: UIViewController) {
        alertController = UIAlertController(title: title,
                                            message: message,
                                            preferredStyle: .alert)
        alertController.addAction(UIAlertAction(title: "OK",
                                                style: .default,
                                                handler: nil))
        view.present(alertController, animated: true)
    }
}

使用方法

AlertUtils.alert(title: "タイトル", message: "メッセージ", view: ViewController())

終わりに

コード貼り付けただけですみません。(特に説明することがない・・・)

1
1
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
1