Taehyeon-Kim / Taehyeon-Kim.github.io

The life of recording is unbreakable
https://taehyeon-kim.github.io
MIT License
1 stars 0 forks source link

SwiftUI101: TextField #31

Open Taehyeon-Kim opened 8 months ago

Taehyeon-Kim commented 8 months ago
TextField(
  "",
  text: $userInformation.text,
  prompt: Text(placeholder)
    .foregroundColor(Color.lightGrey)
)
.textFieldStyle(SignUpTextFieldStyle())
struct SignUpTextFieldStyle: TextFieldStyle {
  func _body(configuration: TextField<Self._Label>) -> some View {
    configuration
      .padding()
      .font(.MC.text)
      .foregroundStyle(Color.MC.writtenGrey)
      .background(.white)
      .overlay {
        RoundedRectangle(cornerRadius: 4, style: .continuous)
          .stroke(Color.MC.lightGrey, lineWidth: 1)
      }
  }
}
Taehyeon-Kim commented 8 months ago

https://softwareanders.com/swiftui-textfield-placeholder-best-practices-and-tips/