Asset Color Catalog | Swift Tutorial

Asset Color Catalog is the feature of XCode 9. BY the use of this feature we can maintain the colors easily and avoid the mistakes. We can create the color catalog in .xcassets and use that color in all over se of color name.

Creating color set in asset catalog (.xcassets)

Select the .xcassets directory in Xcode and select the plus button on the bottom left and select New Color Set. Change the name of your color at right top corner and change the color RGB value according to you. Make sure your color name is unique to other color which are defined by you in same project.

 

Asset catalog colors in Storyboards

We can use this asset catalog color in Storyboard and Interface Builder file. When you selecting the color for views, You can see your color under the “Named colors”.

Asset catalog colors by code

let color: UIColor
if #available(iOS 11.0, *) {
    color = UIColor(named: "blueColor")!
} else {
    color = UIColor(red: 84.0/255.0, green: 128.0/255.0, blue: 255.0/255.0, alpha: 1.0)
}

Create color in Xcode/storyboard use for all projects

We can also create the color in storyboard and use this color in your Xcode for all projects.

Download Demo From here

Leave a Reply

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.