Color Assets in iOS

Updated 24 January 2024

Save

In this article, we will explore the basics of Color assets in iOS.

In Xcode, you can also create color assets that will save a lot of time for developers to manage the color.

What are Color Assets?

Color Assets in iOS reside under the .xcassets folder of your project directory.

You can use a color picker to assign the color and then call that color’s name in your app whenever it is required.

How to create Color Assets?

  1. Create a project in Xcode.
  2. Navigate to Assets.xcassets file in your project.
  3. Click the + in the bottom left
  4. Select Colour Set from the menu.
  5. Rename the colour set by double clicking on it.

Color Assets in iOS

Now select the color inside your colour assets and set your color in RGB or in hexadecimal form.

You can select which devices can use this color asset, you can also mention the colours for Light and Dark modes, and change the colours based on localization used in your application.

Color Assets in iOS

Color Assets in Storyboard 

Using color assets in the storyboard is pretty easier when you tap a color in the interface builder you can see your color name and set it for UIView, UILabel etc.

Conor Assets in iOS

Color Assets in Code

If you want to use the Color Asset in your code, you need to call it like below.

Conclusion

Using Color Assets are quite helpful for the application that uses Dark and Light modes.

Using Color assets for various localisations save the time and energy of the developers.

We hope this article is helpful for you to understand the usage of Color Assets in iOS.

Please check my other blogs here.

You may also check our Flutter app development page.

author
. . .

Leave a Comment

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


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home