XCode Tip: Color Palette

When dealing with custom colors in my apps, I always just make a UIColor Category (aka Extension in Swift), because I’ve found that to be a lot easier than having to punch in the color values in Interface Builder for everything. However, recently I learned that there is a very easy way to make a custom Color Palette that can be used in Interface Builder and shared across a team and even projects!

Create a Color Palette

To create a Color Palette, go to the Interface Building, and select the first view you need to change the background color for. This is where you can start creating a new Palette if your designer gave you a color guide:

Getting the RGB Values

If you do need the RGB Color values for your code, just open up your Color Palette -> Select the Color you need RGB for -> Switch to the RGB Sliders tab to view the RGB values:

Notice at the end there than you can switch to other Color sliders as well to get the needed format for each color.

Sharing

Your new Color Palette is now located in your Library -> Colors directory:

Colors Path

One thing to note is that your Library directory is not visible by default on the Mac. You’ll have to follow these instructions to make your hidden files visible on your Mac.

You can now share this file with your team, including your designer. Once they place it into their Mac’s Colors directory, they will see it! The cool part about this is the Color Palette will be now be visible from any other application, including Photoshop. In fact, you can get your designer to populate the palette from Photoshop, and then send it out to the team. As long as each person adds the most updated Color Palette to their Colors directory, you can now all use it from the Interface Builder!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.