Hey guys, I am new to Quartz 2D and have been trying to figure this out. I have a window based app and a UIView as a sub view of it. All I am simply trying to do is draw and line with the following code:
- (void)drawRect
CGRect)rect {
NSLog(@"I am trying to draw");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 6.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, 100.0f, 100.0f);
CGContextAddLineToPoint(context, 200.0f, 200.0f);
CGContextStrokePath(context);
}
When I run that nothing happens. I have tried to use
[self setNeedsDisplay:YES] and still nothing. Maybe I dont know where to put the setNeedsDisplay? or maybe I am missing a framework? or maybe I am not importing something or making a Quartz 2D delegate? Any help would be greatly appericated!!
Thanks.
- (void)drawRect
NSLog(@"I am trying to draw");
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 6.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, 100.0f, 100.0f);
CGContextAddLineToPoint(context, 200.0f, 200.0f);
CGContextStrokePath(context);
}
When I run that nothing happens. I have tried to use
[self setNeedsDisplay:YES] and still nothing. Maybe I dont know where to put the setNeedsDisplay? or maybe I am missing a framework? or maybe I am not importing something or making a Quartz 2D delegate? Any help would be greatly appericated!!
Thanks.