Member-only story

How to create a loading screen for any SwiftUI app with just two modifiers — Redacted and Shimmer

ML Musings
3 min readJan 5, 2023

--

Learn how to add shimmer effect to text views and card views to make it more intuitive and pretty

Photo by Victor Carvalho on Unsplash

Before we start, let’s get some terms out of the way:

“SwiftUI is an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. Build user interfaces for any Apple device using just one set of tools and APIs. — Wikipedia. The best part is, you can integrate your views with components from UIKit, AppKit and WatchKit framework. SwiftUI has made building user interface straightforward.” — Apple Developer Xcode SwiftUI

Redacted is a SwiftUI modifier that allows you to mark text as a placeholder in your view. What does that mean? When the text gets rendered, redacted will mask it to show that it is just a placeholder and not the content. You can use it in several ways:

  • You can redact a single Text
Text("Redact Me").redacted(reason: .placeholder)
  • You can redact an entire View
VStack {
Text("Redact")
Text("Me")
}.redacted(reason: .placeholder)
  • You can un-redact a redacted View
Image(systemName: "book").unredacted()

--

--

ML Musings
ML Musings

Written by ML Musings

✨ I enjoy pushing the boundaries of JS, Python, SwiftUI and AI. You can support my work through coffee - www.buymeacoffee.com/MLMusings

No responses yet