Instance Method

textContentType(_:)

Sets the text content type for this view, which the system uses to offer suggestions while the user enters text on an iOS or tvOS device.

Declaration

func textContentType(_ textContentType: UITextContentType?) -> some View

Parameters

textContentType

One of the content types available in the UITextContentType enumeration that identify the semantic meaning expected for a text-entry area. These include support for email addresses, location names, URLs, and telephone numbers to name just a few.

Discussion

Use textContentType(_:) to set the content type for this view.

In this example, the TextField is configured for the entry of email addresses.

TextField("billjames2@icloud.com", text: $emailAddress)
    .textContentType(.emailAddress)
}

See Also

Adjusting Text in a View

func keyboardType(UIKeyboardType) -> View

Sets the keyboard type for this view.

func font(Font?) -> View

Sets the default font for text in this view.

func lineLimit(Int?) -> View

Sets the maximum number of lines that text can occupy in this view.

func lineSpacing(CGFloat) -> View

Sets the amount of space between lines of text in this view.

func multilineTextAlignment(TextAlignment) -> View

Sets the alignment of multiline text in this view.

func minimumScaleFactor(CGFloat) -> View

Sets the minimum amount that text in this view scales down to fit in the available space.

func truncationMode(Text.TruncationMode) -> View

Sets the truncation mode for lines of text that are too long to fit in the available space.

func allowsTightening(Bool) -> View

Sets whether text in this view can compress the space between characters when necessary to fit text in a line.

func textContentType(WKTextContentType?) -> View

Sets the text content type for this view, which the system uses to offer suggestions while the user enters text on a watchOS device.

func flipsForRightToLeftLayoutDirection(Bool) -> View

Sets whether this view flips its contents horizontally when the layout direction is right-to-left.

func autocapitalization(UITextAutocapitalizationType) -> View

Sets whether to apply auto-capitalization to this view.

func disableAutocorrection(Bool?) -> View

Sets whether to disable autocorrection for this view.