元柔道整復師エンジニアBlog

- 元柔道整復師エンジニアBlog -

『 エンジニアをリングする。』

【Swift】 UIButtonボタンの有効化・無効化を設定をする

環境

目的

  • UIButtonボタンの有効化・無効化の設定をする

実行

UIButtonボタン定義後に、ボタンに対し有効化・無効化の設定をisEnabledで行う。
isEnabledには、真偽値を設定する。

// ボタン定義
@IBOutlet weak var button: UIButton!
・
・
// 有効化・無効化の設定
self. button.isEnabled = true  // 有効
self. button.isEnabled = false // 無効

まとめ

  • ボタン押下時の順不動な処理を防ぐ。
  • ボタンの重複押下への対策となる。