Be my SwiftUI Valentine
TL;DR funny ways how to use SwiftUI modifiers

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
Search for a command to run...
TL;DR funny ways how to use SwiftUI modifiers

I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 🇩🇪 and happily living in 🇺🇸
No comments yet. Be the first to comment.
WWDC26 kicked off on June 8, 2026. The information in this article reflects the information published by Apple on that date. There are 14 new frameworks. Name Description AccessoryAccess Manage

WWDC25 kicked off on June 9, 2025. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AlarmKitSchedule prominent alarms and countdowns to help people manage their time. AVR...

WWDC25 is almost here, and I couldn’t be more excited! Whether you're attending the official events, community meetups, or just soaking in the energy around Cupertino, there’s no better time to connect, share ideas, and celebrate everything we love a...

In this blog post, I’ll share an observation and advice regarding the caching behavior of network responses by Apple’s APIs. If you are unfamiliar with caching of network responses then I recommend Apple’s article Accessing cached data that introduce...
WWDC24 kicked off on June 10, 2024. The information in this article reflects the information published by Apple on that date. New Frameworks NameDescription AccessorySetupKitUse AccessorySetupKit to discover accessories with Bluetooth or Wi-Fi...

This not-so serious blog post illustrates the use of various SwiftUI view modifiers. The inspiration of this blog post is Valentine's Day 2022 :)
Valentine's Day is on February 14th and I don't want to stand with empty hands in front of my spouse. So let's mark the calendar.
struct MarkYourCalendar: View {
@State private var vDay = Date("20220214")
var body: some View {
DatePicker(
"Start Date",
selection: $vDay,
displayedComponents: [.date]
)
.datePickerStyle(.graphical)
}
}
Using the datePickerStyle view modifier to pass in the graphical will display display an interactive calendar (or clock).

There are other DatePickerStyle's to specify the appearance and interaction of all date pickers within a view hierarchy.
The complete list of types:
P.S.: I am using here an extension on Date to initialize an instance from a string
extension Date {
init(_ input: String) {
self = Date.from(input)
}
static func from(_ input: String) -> Date {
let df = DateFormatter()
df.dateFormat = "yyyyMMdd"
return df.date(from: input) ?? Date()
}
}
The redacted view modifier is a great way to hide sensitive data and to handle loading states. In my case I don't want my spouse to know the gift just yet.
struct ValentinesDayGift: View {
var body: some View {
HStack {
Text("I bought my wife: ")
Text("She cannot know yet").redacted(reason: .placeholder)
}
}
}

Learn more about the redacted view modifier by reading https://serialcoder.dev/text-tutorials/swiftui/the-redacted-view-modifier-in-swiftui/
Using the mask view modifier let's me create this wonderful Valentine's Day card in SwiftUI.
struct ValentinesDayGift: View {
var body: some View {
VStack(spacing: 20) {
Text("Happy Valentine's Day")
.font(.largeTitle)
.fontWeight(.bold)
.foregroundColor(.white)
Image("Jeanine")
.resizable()
.frame(width: 200, height: 200)
.mask(
Image(systemName: "heart.fill")
.resizable()
)
}
.frame(
maxWidth: 500,
maxHeight: 300
)
.background(.purple)
}
}

My wife thinks I am dorky but sweet. She was very happy with her special Valentine's Day card. Mission accomplished :)
The mask() modifier is different from clipShape(), because it also applies any transparency from the masking view – you get to have holes in your underlying view based on the transparency of your mask.
Learn more about the mask view modifier by reading https://www.fivestars.blog/articles/swiftui-masking/