Skip to content
Nick Sarno edited this page Apr 9, 2022 · 2 revisions

.withFont

Use .withFont to easily add font-related modifiers to any View.

Text("Hello, world.")
     .withFont(font: .headline, color: .red)

Optionally customize the lineLimit and minimumScaleFactor.

Text("Hello, world.")
     .withFont(font: .headline, color: .red, lineLimit: 3, minimumScaleFactor: 0.7)

.withFontAnimatable

Use the animatable method if the font color should animate. The color will animate using colorMultiply, since foregroundColor is not animatable by default.

Text("Hello, world.")
     .withFontAnimateable(font: .headline, color: isActive ? Color.red : .blue)
Clone this wiki locally