BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

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

1      

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.

1      

Hacking with Swift is sponsored by Guardsquare

SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.

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.