drawRect context Error
Posted
by user361228
on Stack Overflow
See other posts from Stack Overflow
or by user361228
Published on 2010-06-08T17:45:29Z
Indexed on
2010/06/08
17:52 UTC
Read the original article
Hit count: 446
Hi, I heard that a lot of people get a context error by not using drawRect
Now I have this:
- (void)drawRect:(CGRect)rect {
NSLog(@"drawRect: Starts");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetLineWidth(context, 3.0);
CGContextMoveToPoint(context, lineStart.x, lineStart.y);
CGContextAddLineToPoint(context, lineEnd.x, lineEnd.y);
CGContextStrokePath(context);
}
Error:
<Error>: CGContextSetRGBStrokeColor: invalid context
Which had work on previous programs, but not on this one. Whats different: I have a view controller, which calls this UIView:
-(void)createLine:(CGPoint)start:(CGPoint)end {
NSLog(@"createLine: Starts");
lineEnd = start;
lineStart = end;
self = [super initWithFrame:drawRect:CGRectMake(fmin(lineStart.x, lineEnd.x), fmin(lineStart.y, lineEnd.y), fabs(lineStart.x - lineEnd.x), fabs(lineStart.y - lineEnd.y))];
}
This is my first question, and I am not sure how much info code I should be putting here so be easy on me :D
Thanks
© Stack Overflow or respective owner