GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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.

4      

Hacking with Swift+

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and more!

Learn more here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.