How do I make my own custom UIColor’s other than the preset ones?

You can write your own method for UIColor class using categories.

#import <UIKit/UIKit.h>
@interface UIColor(NewColor)
+(UIColor *)MyColor;
@end

#import "UIColor-NewColor.h"
@implementation UIColor(NewColor)
+(UIColor *)MyColor {
     return [UIColor colorWithRed:0.0-1.0 green:0.0-1.0 blue:0.0-1.0 alpha:1.0f];
}

By this way, you create a new color and now you can call it like

[UIColor MyColor];

You can also implement this method to obtain random color.
Hope this helps.

Leave a Comment