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

Does .accentColor() work in SwiftUI 2?

Forums > SwiftUI

I'm following along with Paul's example and all was going well until I got to this.

It doesn't matter where, and on what Views I add the modifier, it has no effect at all.

Is it a bug or am I missing something? It seems a bit too fundamental and simple for a bug ...

3      

I am not sure which example you are following but you need to add to Color as treat as a color like .black

Color.accentColor
.background(Color.accentColor)
.foregroundColor(.accentColor)

3      

@NigelGee, I think @BlackTablet is referring to the .accentColor(_:) view modifier in SwiftUI, not the static var Color.accentColor. AFAIK, it should work in SwiftUI 2 but I can't check right now.

3      

Yes @roosterboy, I've tried the modifier on Text(), HStack() and VStack() to no effect. Other modifiers work as expected but this does nothing.

apologies for not being clearer.

3      

It was me being stupid I'm afraid.

With all the newness of SwiftUI and modifiers() everywhere I forgot that accent colour is only for the text of controls, not just any old text in my interface, which is what I was thinking!

Apologies.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

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.