set on textfield swiftui code example
Example 1: add textfield in swiftui
struct ButtonAndTextFieldView : View {
@State var text: String = ""
var body: some View {
HStack {
TextField($text,
placeholder: Text("type something here..."))
Button(action: {
// Closure will be called once user taps your button
print(self.$text)
}) {
Text("SEND")
}
}
}
}
Example 2: how to style textfield swiftui
TextField("Enter some text", text: $yourBindingHere)
.textFieldStyle(RoundedBorderTextFieldStyle())