How can we use Assets Catalog Color Sets?

elGeekalpha picture elGeekalpha · Jun 6, 2017 · Viewed 40.7k times · Source

I usually use custom UIColors on iOS using extensions with Swift, but now with iOS 11/ Xcode 9 we can create Colors Sets. How can we use them?

Update - Tip

As @Cœur says we can drag&drop de color, and use it like a UIColor object and a possible solution could be use it as a extension:

UIColor as an extension

Or as a constant:

UIColor as a constant

Now I wanna know if we can access them like an UIImage access to an Asset Image or not, like:

UIImage(named: "image-name") -> UIColor(named: "color-name")

Answer

user2421361 picture user2421361 · Jun 9, 2017
UIColor(named: "myColor") 

Source: WWDC 2017 Session 237 —— What's New in MapKit


Caveat: Your project's Deployment Target needs to be set to iOS 11.0.