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

Image.grayscale(1.0) not working for me?

Forums > SwiftUI

I'm playing around with the Image.grayscale() modifier and for some reason, a value of 1.0 doesn't seem to give me a fully desaturated image. Values from 0 up to 0.99 look as expected, but as I go to 1.0 I get more saturation again:

Any idea what's wrong here? The problem also happens when running the app in the Simulator, not just in Preview.


Don't you mean to use .saturation instead of .greyscale ?


I did mean .grayscale(). Why? Shouldn't I use that?

What's the difference between the two? What differentiates them other than that their scales are reversed (.grayscale(0) is no effect, .saturation(1) is no effect)?

It seems that .saturation() can be driven beyond 1.0 to oversaturate an image but that's not something I want to do.


I also couldn't get grayscale to work. I ended up using saturation instead. If you've figured it out let me know.

struct Test: View {
    let isGray: Bool

    var body: some View {
        VStack {
            Image(systemName: "questionmark")
        .saturation(isGray ? 0.0 : 1.0)


Why not just use .opacity on the image? ..... or did you specifically want to try something different?


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!

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.