I've made methods like follow and excute code.
I am confusing about origin of quartz framework after looking follow result image.
Please look at follow code and image.
[in ViewController.m]
Excute a follow method when press UIButton.
- (void)test {
[customView drawCustom];
[customView setNeedsDisplay];
}
[in CustomView.m]
- (void)drawRect:(CGRect)rect {
cgc_Context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(cgc_Context, 5.0);
CGContextSetStrokeColorWithColor(cgc_Context, [UIColor redColor].CGColor);
CGContextMoveToPoint(cgc_Context, 0, 0);
CGContextAddLineToPoint(cgc_Context, 200, 50);
CGContextStrokePath(cgc_Context);
}
- (void)drawCustom {
CGContextSetLineWidth(cgc_Context, 5.0);
CGContextSetStrokeColorWithColor(cgc_Context, [UIColor yellowColor].CGColor);
CGContextMoveToPoint(cgc_Context, 0, 0);
CGContextAddLineToPoint(cgc_Context, 200, 50);
CGContextStrokePath(cgc_Context);
}
[Result screen]
Red Line : result of drawRect
Yellow Line : result of drawCustom
Why does occur different origin point?