textInputFormattingControlVisibility(_:for:)
Specifies which system text formatting controls are available for people to format text.
Declaration
nonisolated func textInputFormattingControlVisibility(_ visibility: Visibility, for placement: TextInputFormattingControlPlacement.Set) -> some View
Parameters
- visibility:
Whether the controls in the given placements may become visible.
- placement:
The onscreen control to modify.
Discussion
A TextEditor with a binding to an AttributedString offers built-in controls for formatting text. These controls appear in different placements depending on the platform. By default, TextEditor shows them in the context menu and in the keyboard toolbar on iOS. See TextInputFormattingControlPlacement.Set for the available placements.
In this example, the formatting accessory bar is shown in a macOS editor:
struct StyledTextEditingView: View {
@State private var text: AttributedString = ""
var body: some View {
TextEditor(text: $text)
.textInputFormattingControlVisibility(.visible, for: .accessoryBar)
}
}See Also
Managing text entry
autocorrectionDisabled(_:)autocorrectionDisabledkeyboardType(_:)scrollDismissesKeyboard(_:)textContentType(_:)textInputAutocapitalization(_:)TextInputAutocapitalizationtextInputBorderShape(_:)TextInputBorderShapetextInputCompletion(_:)textInputSuggestions(_:)textInputSuggestions(_:content:)textInputSuggestions(_:id:content:)textContentType(_:)textContentType(_:)