minimumScaleFactor
Sets the minimum amount that text in this view scales down to fit in the available space.
Declaration
compose().minimumScaleFactor(factor: number)nonisolated func minimumScaleFactor(_ factor: CGFloat) -> some ViewParameters
factor*numberA fraction between 0 and 1 (inclusive) you use to specify the minimum amount of text scaling that this view permits.
Return value
A view that limits the amount of text downscaling.
Discussion
Use the minimumScaleFactor(_:) modifier if the text you place in a
view doesn't fit and it's okay if the text shrinks to accommodate. For
example, a label with a minimum scale factor of 0.5 draws its text in
a font size as small as half of the actual font if needed.
In the example below, the HStack contains a Text label with a
line limit of 1, that is next to a TextField. To allow the label
to fit into the available space, the minimumScaleFactor(_:) modifier
shrinks the text as needed to fit into the available space.
HStack {
Text("This is a long label that will be scaled to fit:")
.lineLimit(1)
.minimumScaleFactor(0.5)
TextField("My Long Text Field", text: $myTextField)
}See also
More in Text and symbols.
- allowsTighteningSets whether text in this view can compress the space between characters when necessary to fit text in a line.
- 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.