14

I've created Color Set in Assets.xcassets, you can see it in screenshot below

enter image description here

And my question is

How to get this color in code ?

Vladyslav Panchenko
  • 1,517
  • 1
  • 19
  • 23
Tikhonov Aleksandr
  • 13,945
  • 6
  • 39
  • 53
  • @Dávid: Color assets are a feature of the Xcode 9 IDE, so the [xcode9] tag makes sense here (I think). On the other hand, it seems to me that the question has been answered before. – Martin R Sep 13 '17 at 16:43
  • @MartinR now I see, re-added the tag, thanks for the input. And I agree that this seems to be a duplicate actually. – Dávid Pásztor Sep 13 '17 at 16:45

1 Answers1

29

You should use this init of UIColor

init?(named name: String) 

For example:

view.backgroundColor = UIColor(named: "Greeny")

And your name of Color in Assets must be the same as parameter in init

Tikhonov Aleksandr
  • 13,945
  • 6
  • 39
  • 53