我不知道我有什么错误:无法将任何视图的返回表达式转换为返回类型某个视图
我尝试了一些东西,但没有任何效果......我在网上一无所获
谢谢你的帮助...
struct LoginView: View {
@Binding var showCreateAccount: Bool
@State private var email = ""
@State private var password = ""
@State private var formOffset: CGFloat = 0
@State private var presentPasswordRecoverySheet = false
var body: some View {
VStack {
VStack(spacing: 40) {
Image("Logo")
Text("Login").font(.title).bold()
VStack {
RoundTextfield(value: self.$email, placeholder: "Email", icon: Image(systemName: "at"),
onEditingChanged: { flag in withAnimation { self.formOffset = flag ? -150 : 0 } })
RoundTextfield(value: self.$password, placeholder: "Password", icon: Image(systemName: "lock"), isSecure: true,
onEditingChanged: { flag in withAnimation { self.formOffset = flag ? -150 : 0 } })
BasicButton(text: "Login") {}
}
Button(action: { withAnimation(.spring() ) { self.showCreateAccount.toggle() } } )
{
HStack { Text("Don't have an account? Sign up.").accentColor(Color.accentColor) }
}
Button(action: { self.presentPasswordRecoverySheet.toggle() } )
{
HStack { Text("Forgot your password?").accentColor(Color.purple) }
}
.sheet(isPresented: self.$presentPasswordRecoverySheet)
{ RecoverPasswordView(presentPasswordRecoverySheet: self.$presentPasswordRecoverySheet) }
}
.padding()
.offset(y: self.formOffset)
}
}
这是我的 BasicButton 代码,但我认为这不是问题
struct BasicButton: View {
var text = "Next"
var action: (()->()) = {}
var body: some View {
Button(action: {
self.action()
}) {
HStack {
Text(text)
.bold()
.frame(minWidth: 0, maxWidth: .infinity)
.padding(.vertical)
.accentColor(Color.white)
.background(Color("accentColor"))
.cornerRadius(30)
}
}
}
}
struct BasicButton_Previews: PreviewProvider {
static var previews: some View {
BasicButton()
}
当我删除创建帐户和忘记密码的两个按钮功能时,代码可以构建