UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Day 20 - Cannot achieve the background material vibrancy effect

Forums > 100 Days of SwiftUI

Hi all, I'm following the Day 20 - Colors and Frames tutorial and tried to make the blurry view with foreground vibrancy enabled. According to the tutorial, we can just change the modifier .foregroundColor(.secondary) to .foregroundStyle(.secondary) to get the text vibrancy effect, so I have this:

var body: some View {
    ZStack {
        VStack(spacing: 0) {
            Color.red
            Color.blue
        }

        Text("Your content")
            .foregroundStyle(.secondary)
            .padding(50)
            .background(.ultraThinMaterial)
    }
    .ignoresSafeArea()
}

But I'm not observing any changes like what was shown in the video and the text is still completely opaque. Any idea why is that? Did Apple change the API?

P.S. my result: https://imgur.com/a/qftqNKD

3      

I think you might have to zoom in 400 percent to see the subtle difference. You can probably try .foregroundStyle(.opacity(0.01) to maybe get the desired effect.

3      

Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.