MayNotBe
MayNotBe

Reputation: 2140

Add custom colors to Xcode attributes inspector

I have a Swift class that extends UIColor and has functions like:

class func buttonShadowColor() -> UIColor
{
    return UIColor(red:0.74, green:0.74, blue:0.74, alpha:1)
}

Is there any way to add these colors to the "text color" (or any dropdown) in the attributes inspector so they can be used app wide from the storyboard?

enter image description here

Upvotes: 2

Views: 1371

Answers (2)

Quinn Taylor
Quinn Taylor

Reputation: 44769

There wasn't a way to do this at the time you asked, but Xcode 9 adds named colors to asset catalogs, and they automatically appear in color properties in IB's inspectors. :-)

Upvotes: 2

Glorfindel
Glorfindel

Reputation: 22641

If you use the color only once, it will appear in the Recently Used Colors (the most recently used will appear on the left).

When you open the color picker, and select the Sliders tab, you can choose your desired color. When you're done, you can drag the color from the bottom left to one of the spots on the bottom right.

enter image description here

It is not possible to modify the list of basis colors (the one which starts with Dark Text Color).

Upvotes: 0

Related Questions