Xcode 4.3 How to programmatically access the colors of an interface palette?

I create an interface in the interface builder and see that there are many color palettes for choosing the font and background colors:

background color>other>color widget 3rd tab > Palette 

Some of them have strange names, such as "Ice", "Sky", etc.

From my code, I have access to

 [UIColor blueColor]; [UIColor cyanColor]; 

Is there a way to access these extra colors by name from my code? For example,

 //Is there a method call that does something like this? [Color colorNamed:@"Ice" inPalette:@"Apple"]; 

Thanks!

+7
source share
1 answer

You will need to get the RGB values โ€‹โ€‹of the colors you need from the colors of the pencil. You can access them this way, "Sky" will be: [UIColor colorWithRed:(102.0/255.0) green:(204.0/255.0) blue:(255.0/255.0) alpha:1.0];

Or add UIColor categories that add all the colors you need: [UIColor skyColor];

In UIColor+Colors.h add:

 @interface UIColor (Colors) +(UIColor *)skyColor; @end 

In UIColor+Colors.m add:

 @implementation UIColor (Colors) +(UIColor *)skyColor { static UIColor *color = nil; if (!color) color = [[UIColor alloc] initWithRed:(102.0/255.0) green:(204.0/255.0) blue:(255.0/255.0) alpha:1.0]; return color; } @end 
+9
source

All Articles