Learn Courses My Dashboard

Colours as variables?

hey, I have been playing around with some stuff in Xcode, and I am trying to create in a model a variable that is a colour, I have had some success storing and using a colour picker to put into a var and then use that var in a view.

as you can see it works fine.
but as soon as I try to put that into a model, to use in ForEach loops and that kind of thing, all of a sudden it has a problem.

I have searched google, but my google powers aren’t strong enough this time, I have no idea why it’s not working, any ideas?
as always thanks for helping me with what is probably something incredibly simple!

Did you import SwiftUI?

You need to import SwiftUI in order to use Color; otherwise you can import UIKit and use UIColor instead.

Yes! thank you so much!
I imported swiftUI and then just Color worked as a data type!
thank you v

thank you much!