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
title
The title of
self
, used as a placeholder.value
The underlying value to be edited.
formatter
The
Formatter
to use when converting between theString
the user edits and the underlying value of typeT
. In the event thatformatter
is unable to perform the conversion,binding.value
will not be modified.onEditingChanged
An
Action
that will be called when the user begins editingtext
and after the user finishes editingtext
, passing aBool
indicating whetherself
is currently being edited or not.onCommit
The action to perform when the user performs an action (usually the return key) while the
TextField
has focus. -
Sets if this view is the first responder or not.
Setting a value of
true
will make this view become the first responder if not already. Setting a value offalse
will 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
title
The title of
self
, used as a placeholder.text
The text to be displayed and edited.
isSecureTextEntry
Specifies if text entry will be masked.
onEditingChanged
An
Action
that will be called when the user begins editingtext
and after the user finishes editingtext
, passing aBool
indicating whetherself
is currently being edited or not.onCommit
The action to perform when the user performs an action (usually the return key) while the
TextField
has focus.