Swift「disabled」でButtonを無効にするサンプル
環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)
Ubuntu 20.04.2 LTS
構文
func disable ( _ disabled : Bool ) -> some View
引数の値がtrueならばボタンを無効にし、falseならボタンを有効にします。
使用例
Button(action: {
}) {
Text("表示")
}
.disabled(true)
Button(action: {
}) {
Text("表示")
}
.disabled(true)
Button(action: { }) { Text("表示") } .disabled(true)