Type Safely

Type Safely

Set SwiftUI backgroundColor the same way as foregroundColor

Daily Coding Tip 009

Type Safely's avatar
Type Safely
Dec 27, 2020
∙ Paid
Image by SS-Lw from Pixabay

It’s useful that SwiftUI has a modifier called .background() so that you can add any kind of view behind the current view. Instead of being limited to colour, your background could be an image or a more complicated shape. But when I use the .foregroundColor() modifier, I take advantage of the fact that a Color is expected by g…

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