New in SwiftUI 3: foregroundStyle

DevTechie
DevTechie
Oct 15, 2021 · 3 min read

Introduced in iOS 15 and SwiftUI 3, foregroundStyle is a new modifier which can be used to apply color or pattern as foreground to view. This modifier can be applied to style content of text, shapes, symbols, images etc.

Let’s start by setting foreground style with orange color:

struct ForegroundStyleExample: View {
var body: some View {
VStack {
Text("DevTechie")
Image(systemName: "globe")
Capsule()
.frame(height: 50)
.overlay {
Text("SwiftUI 3")…