Global Color Palette for Interface Builder
The best solution I have found to this problem is to build an asset catalog of house colors, which can be used by Interface Builder.
https://help.apple.com/xcode/mac/current/#/dev10510b1f7
As far as I know, you can't programatically define colors that will then show up in Interface Builder, but you can extend UIColor
for custom colors to use in your code:
extension UIColor {
static func myCustomColor() -> UIColor {
return UIColor(red: 23/255.0, green: 175/255.0, blue: 72/255.0, alpha: 1.0)
}
}
And to reference the custom color:
myView.backgroundColor = UIColor.myCustomColor()
This doesn't completely solve your issue, but it could potentially be better to set colors programatically than through IB. It would allow you to adjust a value one time in code to change a color throughout the app rather than having to adjust it multiple times for each UI element through Interface Builder.