xCode 4.3 how to programmatically access interface builder palette colors?

I'm building the interface within interface builder and see that there's a variety of color palettes available for selecting font and background colors:

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

Some of them have weird names like "Ice", "Sky", etc.

From my code I have access to

[UIColor blueColor];
[UIColor cyanColor];

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

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

Thank you!

Answers


You would need to get the RGB values of the colors you need from the crayon colors. You could access them that way, "Sky" would 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 of 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

Need Your Help

UIViewController _loadViewFromNibNamed:bundle loaded the "XXXViewController" nib but the view outlet was not set.' -*Using Storyboard*

xcode uinavigationcontroller storyboard nib

I am using Storyboard to navigate through my View Controllers. I have my Root View Controller called (RootVC) which I've hooked up to the next view controller (called SecondVC) with a 'push' segu...

SQL not in to Linq

c# sql linq nhibernate linq-to-sql

I have a (Oracle)SQL query that I want to translate to Linq to use on a NHibernate context.