1
什么,我试图做的是创建一个自定义进度条,石英图纸,我要做的就是以下,石英绘图古怪
- (void)drawRect:(CGRect)rect {
// Drawing code.
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect currentBounds = self.bounds;
CGContextSetLineWidth(context, 20.0f);
CGContextSetStrokeColorWithColor(context, [ProgressBarView redColor]);
CGContextBeginPath(context);
CGContextMoveToPoint(context, CGRectGetMinX(currentBounds), CGRectGetMidY(currentBounds));
CGContextAddLineToPoint(context, CGRectGetMaxX(currentBounds) * time, CGRectGetMidY(currentBounds));
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathStroke);
}
在CGContextAddLineToPoint我乘maxX的时间的时间,这是每秒钟用这个函数计算。
- (void)pushTime {
if (time >= 1.0) {
time = 0.0;
} else {
time = time += 0.1;
}
[self setNeedsDisplay];
}
它的伟大工程的第一次,但随后的进度条永远不会回到起点,我已经尝试启动值更改为0以外,使石英能够正常创建路径,但那没有做到。
无论如何,感谢您的帮助。
什么“时间”是? INT?浮球?一个NSNumber ...?你在哪里调用pushTime?通过NSTimer? – meronix 2011-03-10 07:20:19