- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
[[UIColor redColor] setStroke];
CGContextSetLineWidth(context, 5);
CGPoint points[5];
points[0] = CGPointMake(100, 30);
points[1] = CGPointMake(120, 130);
points[2] = CGPointMake(140, 30);
points[3] = CGPointMake(160, 80);
points[4] = CGPointMake(180, 100);
CGContextAddLines(context, points, 5);
CGContextStrokePath(context);
for (int i = 0; i < 5; i ++) {
CGRect ellipseRect = CGRectMake(points[i].x - 3, points[i].y - 3, 8, 8);
CGContextAddEllipseInRect(context, ellipseRect);
CGContextSetLineWidth(context, 2);
[[UIColor whiteColor] setStroke];
[[UIColor blackColor] setFill];
CGContextFillEllipseInRect(context, ellipseRect);
CGContextStrokeEllipseInRect(context, ellipseRect);
}
}
iOS简单画折线图
最新推荐文章于 2024-05-26 10:03:34 发布