I have a UIColor initiated with [UIColor colorWithRed:Green:Blue:Alpha] and I want to extract its corresponding CGColor to use with CGContextSetFillColorWithColor.
I tried [[UIColor colorWithRed...] CGColor] but for some reason I get no coloring.
I
[[UIColor colorWithRed:216 green:156 blue:1 alpha:1] CGColor]
The weird thing is that when I use:
[[UIColor orangeColor] CGColor]
It works just fine.
Any ideas? Thanks!
EDIT:
The actual code:
CGRect rect = CGRectMake(0.0, 0.0, width, height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor colorWithRed:216 green:156 blue:1 alpha:1].CGColor);
CGContextFillRect(context, rect);
self.image = UIGraphicsGetImageFromCurrentImageContext();
I don't think its code-related - again, if I change the UIColor to a constant color it all works.
The purpose of the code is to create an UIImage filled with a specific color.