Warning: Undefined array key 2 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 15
Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 18
Warning: Undefined array key 4 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21
Warning: Undefined array key 2 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 27
Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 30
Warning: Undefined array key 4 in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33
このページでは、下の写真のようにUIボタンを無効にする(押せなくする)方法について解説します。

書き方
ボタンを無効にする
UIButtonの変数名.isEnabled = false
ボタンを有効にする
UIButtonの変数名.isEnabled = true
例
ボタンを無効にする
import UIKit
class ViewController: UIViewController {
// ボタンの変数
@IBOutlet weak var sampleButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//ボタンを非表示にする
sampleButton.isEnabled = false
}
}
これで、ボタンが無効になり押せなくなります。



