Declaration
compose().tracking(tracking: number)nonisolated func tracking(_ tracking: CGFloat) -> TextParameters
tracking*numberThe amount of additional space, in points, that the view should add to each character cluster after layout. Value of
0sets the tracking to the system default value.
Return value
Text with the specified amount of tracking.
Discussion
Tracking adds space, measured in points, between the characters in the text view. A positive value increases the spacing between characters, while a negative value brings the characters closer together.
VStack(alignment: .leading) {
Text("ABCDEF").tracking(-3)
Text("ABCDEF")
Text("ABCDEF").tracking(3)
}The code above uses an unusually large amount of tracking to make it easy to see the effect.
The effect of tracking resembles that of the Text.kerning(_:)
modifier, but adds or removes trailing whitespace, rather than changing
character offsets. Also, using any nonzero amount of tracking disables
nonessential ligatures, whereas kerning attempts to maintain ligatures.
See also
More in Text modifiers.
- accessibilityHeadingSets the accessibility level of this heading.
- accessibilityLabelAdds a label to the view that describes its contents.
- accessibilityTextContentTypeSets an accessibility text content type.
- baselineOffsetSets the vertical offset for the text relative to its baseline.
- boldApplies a bold font weight to the text.
- fontSets the default font for text in the view.
- fontDesignSets the font design of the text.
- fontWeightSets the font weight of the text.
- fontWidthSets the font width of the text.
- foregroundStyleSets the style of the text displayed by this view.
- italicApplies italics to the text.
- kerningSets the spacing, or kerning, between characters.