【发布时间】:2019-06-12 03:06:29
【问题描述】:
我正在使用 SwiftUI 框架创建一个SignUp 屏幕。
我有两个文本字段,FirstName 和 LastName,还有一个按钮。
我将它们归为VStack。
当我运行应用程序时,按钮是可点击的,但我无法在文本字段中输入任何内容。
这是我的代码:
@State var firstName = ""
@State var lastName = ""
var body: some View {
NavigationView {
VStack {
VStack {
VStack {
Group {
TextField($firstName, placeholder: Text("First Name")).padding(10)
}.background(Color.white).clipShape(RoundedRectangle(cornerRadius: 5))
.shadow(radius: 3)
Group {
TextField($lastName, placeholder: Text("Last Name")).padding(10)
}.background(Color.white).clipShape(RoundedRectangle(cornerRadius: 5))
.shadow(radius: 3)
Button(action: {
}) {
Group {
Text("Create User").color(.white).padding(10)
}.background(Color.blue).clipShape(RoundedRectangle(cornerRadius: 5))
.shadow(radius: 5)
}
}.padding(12)
.background(Color.gray)
.shadow(radius: 5)
}.background(Color.gray)
}.navigationBarTitle(Text("Sign Up"))
}
}
【问题讨论】:
标签: ios swift user-interface textfield swiftui