Arun
Arun

Reputation: 117

XCode 12.2 color literal from assets

Before if we drag assets colorliteral we can see the color with rgb but now if we drag color from assets it shows syntax like "color("filename"), how can i get old xcode like result in xcode 12.2 https://i.sstatic.net/3gsUK.jpg

Upvotes: 1

Views: 824

Answers (1)

Ian L
Ian L

Reputation: 5591

It's not ideal but you can use UIColor(named: "CaseTypePrivate")

I can't seem to find any way to get the #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1) that we used to get when you drag-and-dropped from the assets menu.

One bonus at least of the first answer is that it will reflect any changes you make to your color assets; whereas the colorLiteral approach effectively hard-codes the color value.

Upvotes: 1

Related Questions