Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we use Assets Catalog Color Sets?

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") 
like image 558
elGeekalpha Avatar asked Jun 06 '17 18:06

elGeekalpha


1 Answers

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.

like image 194
user2421361 Avatar answered Sep 28 '22 20:09

user2421361