Define a global color
You should create a category, not a subclass. This will extend the UIColor class, and add your colors to it.
.h
#import <UIKit/UIKit.h>
@interface UIColor (CustomColors)
+ (UIColor *)myColorLightGreyBGColor;
@end
.m
#import "UIColor+CustomColors.h"
@implementation UIColor (CustomColors)
+ (UIColor *)myColorLightGreyBGColor {
static UIColor *lightGreyBGColor;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
lightGreyBGColor = [UIColor colorWithRed:241.0 / 255.0
green:241.0 / 255.0
blue:241.0 / 255.0
alpha:1.0];
});
return lightGreyBGColor;
}
@end
By defining your colors this way, and #importing the category, you can apply this custom color the way you were already trying to.
How about a macro?
#define DEFAULT_COLOR_BLUE [UIColor colorWithRed:.196 green:0.3098 blue:0.52 alpha:1.0]
Put it in your appname_Prefix.pch file or more likely a header file included in your prefix file
And it will be like:
cell.backgroundColor = DEFAULT_COLOR_BLUE;
Your class name is lightGreyUIColor
Hence you need to use it as
cell.backgroundColor = [lightGreyUIColor lightGreyBGColor];
Or you need to create a category on UIColor
.
EDIT:
Your code [UIColor lightGreyBGColor]
tries to search for the method in UIColor
itself, however you have subclassed UIColor
by lightGrayUIColor
.
As you are calling, it looks like you intended for a category.
Side Note: ClassName should be captial as LightGreyUIColor
.