Max*_*iel 1 core-graphics cs193p drawrect ios
我正在研究斯坦福CS193p课程,我正在尝试绘制图表.绘制轴有效,但我无法绘制图形本身.我收到了消息
CGContextAddLineToPoint: no current point.
Run Code Online (Sandbox Code Playgroud)
当我试图画画.这是代码.
- (void)drawRect:(CGRect)rect
{
NSLog(@"Drawing Graph View");
CGPoint origin = CGPointMake(20, 350);
CGRect rect2 = CGRectMake(origin.x, origin.y, 250, -250);
[AxesDrawer drawAxesInRect:rect2 originAtPoint:origin scale:[self scale]];
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
CGContextSetLineWidth(context, 2);
[[UIColor redColor] setStroke];
CGContextMoveToPoint(context, origin.x, origin.y);
for (CGFloat i=0; i<250; i++) {
CGFloat yChange = [self.dataSource deltaY:self];
CGContextAddLineToPoint(context, origin.x+i, origin.y-yChange);
CGContextStrokePath(context);
}
UIGraphicsPopContext();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1701 次 |
| 最近记录: |