2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UIButtonのisEnabledの切り替え

Last updated at Posted at 2020-08-29

#UIButtonのisEnabledの切り替えをする

条件を満たしていないときにボタンが押せない、みたいな処理の切り替えをしたい時は

isEnabled

viewController.swift
class ViewController: UIViewController {
 
    @IBOutlet weak var button: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        button.isEnabled = true // ボタン有効
        button.isEnabled = false // ボタン無効
    }
}

こうすればアクションを制限できます。

2
4
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
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?