import SwiftUI
struct LoginScreen: View {
@State private var username = ""
@State private var password = ""
var body: some View {
VStack(spacing: 20) {
TextField("Username", text: $username)
.textFieldStyle(RoundedBorderTextFieldStyle())
.autocapitalization(.none)
.disableAutocorrection(true)
SecureField("Password", text: $password)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button("Login") {
// Action on login tap
}
.frame(maxWidth: .infinity)
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding()
}
}
struct LoginScreen_Previews: PreviewProvider {
static var previews: some View {
LoginScreen()
}
}This login screen uses SwiftUI's TextField for the username and SecureField for the password. The SecureField automatically hides the typed characters, showing dots instead, which is perfect for passwords. The button is styled with a blue background and white text to stand out. The username field disables autocorrection and capitalization to make typing easier and more accurate for usernames.