Type Safely

Type Safely

Use a Gradient As The Foreground Style of a Text

Daily Coding Tip 281

Type Safely's avatar
Type Safely
Apr 14, 2023
∙ Paid
Photo by Adrian Infernus on Unsplash

Before iOS 15 there was no .foregroundStyle(_:) modifier, so it was a bit more tricky to use a gradient this way. In iOS 15 and newer versions all we have to do is pass the gradient. This is because LinearGradient conforms to the ShapeStyle protocol as well as the View protocol.

This is an app that lets you use a TextF…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture