Quarz 2D 绘图问题求教

来源:互联网 发布:詹姆斯生涯结束后数据 编辑:程序博客网 时间:2024/05/17 02:16

我取了一个数组:array,数组中的元素是通过一个定时器,每10秒添加一个,并调用 setneedsdisplay。


然后我的drawRect是这样写的:

- (void)drawRect:(CGRect)rect {

CGContextRef context =UIGraphicsGetCurrentContext();

CGContextSetLineWidth(context,2.0);

   CGContextSetRGBStrokeColor(context,0.231, 0.656, 0.849,1.0);

   CGContextBeginPath(context);

for (int i=0; i< list.count; i++) {

firstPoint =CGPointMake(40 + [[listobjectAtIndex:i]floatValue],130);

        lastPointCGPointMake(40 + [[listobjectAtIndex:i]floatValue],130-self.journey);

        CGContextMoveToPoint(context, firstPoint.x, firstPoint.y);

        CGContextAddLineToPoint(context, lastPoint.x, lastPoint.y);

    }

CGContextStrokePath(context);

    }


为什么每次只是绘制了一条线!?而不是连成一个整体的线条?!!!


原创粉丝点击