I've created Color Set in Assets.xcassets, you can see it in screenshot below
And my question is
How to get this color in code ?
Create a new file (⌘N) and select the Asset Catalog template in the iOS – Resource panel. Choose a name, select the targets that should include the catalog, and click “Create.” Select the new *. xcassets file in the project explorer.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With