TextField
public struct TextField<T> : View
extension TextField: Renderable
A view that allows text input in one line.
-
Declaration
Swift
public var viewStore: ViewValues -
Declaration
Swift
public var body: View { get } -
Create an instance which binds with a value of type
T.Declaration
Swift
public init(_ title: String, value: Binding<T>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {})Parameters
titleThe title of
self, used as a placeholder.valueThe underlying value to be edited.
formatterThe
Formatterto use when converting between theStringthe user edits and the underlying value of typeT. In the event thatformatteris unable to perform the conversion,binding.valuewill not be modified.onEditingChangedAn
Actionthat will be called when the user begins editingtextand after the user finishes editingtext, passing aBoolindicating whetherselfis currently being edited or not.onCommitThe action to perform when the user performs an action (usually the return key) while the
TextFieldhas focus. -
Sets if this view is the first responder or not.
Setting a value of
truewill make this view become the first responder if not already. Setting a value offalsewill make this view resign beign first responder if it is the first responder.Important
Not SwiftUI compatible.Declaration
Swift
public func firstResponder(_ firstResponder: Binding<Bool>) -> TextField<T> -
Declaration
Swift
public func createView(context: Context) -> UIView -
Declaration
Swift
public func updateView(_ view: UIView, context: Context)
-
Creates an instance with a a value of type
String.Declaration
Swift
public init(_ title: String, text: Binding<String>, isSecureTextEntry: Bool = false, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {})Parameters
titleThe title of
self, used as a placeholder.textThe text to be displayed and edited.
isSecureTextEntrySpecifies if text entry will be masked.
onEditingChangedAn
Actionthat will be called when the user begins editingtextand after the user finishes editingtext, passing aBoolindicating whetherselfis currently being edited or not.onCommitThe action to perform when the user performs an action (usually the return key) while the
TextFieldhas focus.
View on GitHub
TextField Structure Reference