Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Use a Gradient As The Foreground Style of a Text
Copy link
Facebook
Email
Notes
More

Use a Gradient As The Foreground Style of a Text

Daily Coding Tip 281

Type Safely's avatar
Type Safely
Apr 14, 2023
∙ Paid

Share this post

Type Safely
Type Safely
Use a Gradient As The Foreground Style of a Text
Copy link
Facebook
Email
Notes
More
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More