Reputation: 471
This piece of code works fine
self.fillColor = [UIColor whiteColor].CGColor;
While this throws an exception in my drawRect function
self.fillColor = [[UIColor whiteColor] colorWithAlphaComponent:0.2].CGColor;
drawRect:
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.fillColor); //exception here
CGContextSetStrokeColorWithColor(context, self.fillColor);
CGContextFillEllipseInRect(context, rect);
CGContextStrokeEllipseInRect(context, rect);
}
What's the issue?
Upvotes: 2
Views: 1247
Reputation: 77661
Ok. It looks like the error is from the way the property is defined.
Try defining it this way...
@property UIColor *fillColor;
Then in drawRect you can use...
fillColor.CGColor
I have done this hundreds of times. Alpha values don't make any difference.
Upvotes: 1