Text input and output
Display formatted text and get text input from the user.
Overview
To display read-only text, or read-only text paired with an image, use the built-in Text or Label views, respectively. When you need to collect text input from the user, use an appropriate text input view, like TextField or TextEditor.
[Image]
You add view modifiers to control the text’s font, selectability, alignment, layout direction, and so on. These modifiers also affect other views that display text, like the labels on controls, even if you don’t define an explicit Text view.
For design guidance, see Typography in the Human Interface Guidelines.
Topics
Displaying text
Getting text input
Selecting text
textSelection(_:)TextSelectabilityTextSelectiontextSelectionAffinity(_:)textSelectionAffinityTextSelectionAffinityAttributedTextSelection
Setting a font
Adjusting text size
textScale(_:isEnabled:)dynamicTypeSize(_:)dynamicTypeSizeDynamicTypeSizeScaledMetricTextVariantPreferenceFixedTextVariantSizeDependentTextVariant
Controlling text style
bold(_:)italic(_:)underline(_:pattern:color:)strikethrough(_:pattern:color:)textCase(_:)textCasemonospaced(_:)monospacedDigit()AttributedTextFormattingDefinitionAttributedTextValueConstraintAttributedTextFormatting
Managing text layout
truncationMode(_:)truncationModeallowsTightening(_:)allowsTighteningminimumScaleFactor(_:)minimumScaleFactorbaselineOffset(_:)kerning(_:)tracking(_:)flipsForRightToLeftLayoutDirection(_:)TextAlignment
Rendering text
Limiting line count for multiline text
Formatting multiline text
Formatting date and time
Managing text entry
autocorrectionDisabled(_:)autocorrectionDisabledkeyboardType(_:)scrollDismissesKeyboard(_:)textContentType(_:)textInputAutocapitalization(_:)TextInputAutocapitalizationtextInputCompletion(_:)textInputSuggestions(_:)textInputSuggestions(_:content:)textInputSuggestions(_:id:content:)textContentType(_:)textContentType(_:)textContentType(_:)TextInputFormattingControlPlacement
Dictating text
Configuring the Writing Tools behavior
Specifying text equivalents
Localizing text
Preparing views for localizationLocalizedStringKeylocaletypesettingLanguage(_:isEnabled:)TypesettingLanguage