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

Related Post

Drag and Drop Table View cell in IOS 11 & swi... Drag and Drop Table View cell in IOS 11 & swift 4
Dart Libraries | Dart Tutorial Dart Libraries Dart has the following libraries, which are included in all Dart platforms: dart:core This library is automatically imported into ev...
Comments in C Comments in C Comments in C language are used to provide information about lines of code. It is widely used for documenting code. There are 2 types o...
Invitation Letter for Visa Invitation Letter Samples These letter are necessary for taking visa of another country. so these samples are the most important document. Sample 1 ...
C Language – Introduction Why C? There are three important aspects of any language so as C has : The way it stores data, The way it operates on this data and How th...
Getting started with C Getting started with C : If we want to communicate with our computer it is very much needed that our computer understands what we want to say to it. ...
Author

Write A Comment