import SwiftUI
struct ContentView: View {
@State var username = ""
@State var email = ""
var disableForm:Bool {
username.count < 5 || email.count < 5
}
var body: some View {
Form {
Section {
TextField("Username", text: $username)
TextField("Email", text: $email)
}
Section {
Button("Create account") {
print("Creating account...")
}
}.disabled(disableForm)
}
}
}
SwiftUI:Form Section disabled
最新推荐文章于 2023-08-09 19:40:56 发布