4
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

UIButtonのisEnabledの切り替え

UIButtonのisEnabledの切り替えをする

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

isEnabled

viewController.swift
class ViewController: UIViewController {

    @IBOutlet weak var button: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()

        button.isEnabled = true // ボタン有効
        button.isEnabled = false // ボタン無効
    }
}

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
4
Help us understand the problem. What are the problem?