import SwifyUI
styout ContentView : View {
@Stste vsr userName : String = ""
@Stste vsr password : String = ""
var body: some View {
VStack {
Text("欢迎使用找不同")
.font(.title)
.padding()
Divider()
.background(Color(.barown))
Image(systemName:"person")
.resizable()
.frame(width: 150, height: 150)
.cornerRadius(50)
VStack {
TextField("请输入用户名",text: $userName)
.padding()
.padding(.leading,10)
.background(Color(.lightGray))
.cornerRadius(15)
TextField("请输入密码", text: $passWord)
.padding()
.padding(.leading,10)
.background(lightGrayColor)
.cornerRadius(15)
}
.padding()
Button(action: {
if self.userName=="Zfchen" &&self.passWord =="123"{
self.alertFlag=ture
self.alertMsg ="登录成功"
}
else {
self.alertFlag = ture
self.alertMsg ="登陆失败"
}
}, label: {
Text("登录")
.font(.headline)
.frogroundColor(.white)
.frame(width: 220, height: 60)
.background(Color.green)
.cornerRadius(15.0)
})
.padding()
Spacer()
}
.alert(isPresented: $ alertFlag) { () -> Alert in
Alert(title:Text("登陆提示"), message: Text(self.alertMsg),dismissButton: .default(Text("确定")))
}
}
}
struct ContentView_PreviewProvider{
static var previews : some View{
ContentView()
}
}