编辑代码

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))//背景色为brown
            Image(systemName:"person")//系统图像person
                .resizable()//允许改变图像尺寸
                .frame(width: 150, height: 150)//尺寸改为150*150
                .cornerRadius(50)//圆角半径50

            VStack {
                TextField("请输入用户名",text: $userName)
                   .padding()//四周默认间隔
                   .padding(.leading,10)//前方间隔10
                   .background(Color(.lightGray))//背景色
                   .cornerRadius(15)//圆角半径15
                TextField("请输入密码", text: $passWord)
                   .padding()//四周默认间隔
                   .padding(.leading,10)//前方间隔10
                   .background(lightGrayColor)//背景色
                   .cornerRadius(15)//圆角半径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()
    }
}