Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/blog/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/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21
Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/blog/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/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33
ある条件を満たすまでは、ボタンやラベルを非表示にしておきたいことってありますよね。
その方法を紹介します。
書き方
UIの変数名.isHidden = true
例
ボタンを非表示にする
import UIKit
class ViewController: UIViewController {
// ボタンの変数
@IBOutlet weak var sampleButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
//ボタンを非表示にする
sampleButton.isHidden = true
}
}
これで、ボタンが非表示になります。
非表示にしたUI部品を再度表示するには?
非表示にしたものを、表示するには逆のことをすればOKです。
つまり、isHiddenの値にfalseを設定すれば表示されます。
UIの変数名.isHidden = false



