Ios – How to define colors in XCodes’ Interface Builder

colorsinterface-builderiosxcode

I would like to copy colors between elements in the Interface Builder or define them using RGB values. For example, I'd like to copy the background color of a button to another button without duplicating the button.

Alternatively, entering exact RGB codes in Interface Builder would suffice; that way I can make sure my buttons have the exact same color.

Currently I only know how to do this programmatically, but surely there is a way to do it in Interface Builder?

Best Answer

To copy a custom-defined color between different elements you should save it. To do this, first define the color in the Colors window (e.g. by entering RGB values into field as described in Vladimir's answer). Then simply drag from the top panel of the colors window where your resulting color is shown into one of the small square boxes at the bottom. It will be saved.

Illustration