0
我已经制作了像follow和excute代码的方法。为什么在石英框架中出现差异原点?
看到跟随结果图像后,我对石英框架的起源感到困惑。
请看下面的代码和图像。
[在ViewController.m]
EXCUTE后续方法时按下的UIButton。
- (void)test {
[customView drawCustom];
[customView setNeedsDisplay];
}
[在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);
}
[结果画面]
红线:drawRect中
黄线的结果:drawCustom
的结果为什么发生不同的起源点?