allowsTightening
Sets whether text in this view can compress the space between characters when necessary to fit text in a line.
Declaration
compose().allowsTightening(flag: boolean)nonisolated func allowsTightening(_ flag: Bool) -> some ViewParameters
flag*booleanA Boolean value that indicates whether the space between characters compresses when necessary.
Return value
A view that can compress the space between characters when necessary to fit text in a line.
Discussion
Use allowsTightening(_:) to enable the compression of inter-character
spacing of text in a view to try to fit the text in the view's bounds.
In the example below, two identically configured text views show the
effects of allowsTightening(_:) on the compression of the spacing
between characters:
VStack {
Text("This is a wide text element")
.font(.body)
.frame(width: 200, height: 50, alignment: .leading)
.lineLimit(1)
.allowsTightening(true)
Text("This is a wide text element")
.font(.body)
.frame(width: 200, height: 50, alignment: .leading)
.lineLimit(1)
.allowsTightening(false)
}See also
More in Text and symbols.
- autocorrectionDisabledSets whether to disable autocorrection for this view.
- baselineOffsetSets the vertical offset for the text relative to its baseline in this view.
- boldApplies a bold font weight to the text in this view.
- findDisabledPrevents find and replace operations in a text editor.
- findNavigatorProgrammatically presents the find and replace interface for text editor views.
- fontSets the default font for text in this view.
- fontDesignSets the font design of the text in this view.
- fontWeightSets the font weight of the text in this view.
- fontWidthSets the font width of the text in this view.
- interactionActivityTrackingTagSets a tag that you use for tracking interactivity.
- italicApplies italics to the text in this view.
- kerningSets the spacing, or kerning, between characters for the text in this view.