我希望绘制一条曲线,直到它完成一个完整的旋转并连接成为一个完整的圆形,而不是圆形轮廓。这必须在几秒钟内动画。iPhone:绘制一条曲线,直到它变成一个圆圈动画
任何人都可以指向正确的方向吗?我已经问过一个similar question这个问题,但是我错误地写了这个问题,所以每个人都很难理解我的意思,于是就迷失在问题的海洋中。
任何帮助
[编辑]
非常感谢我目前子类的UIView和压倒一切的drawRect。我发现代码绘制一个实心圆,但我只需要中风。
- (void)drawRect:(CGRect)rect {
// Drawing code
CGRect allRect = self.bounds;
CGRect circleRect = CGRectInset(allRect, 2.0f, 2.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw background
CGContextSetRGBStrokeColor(context, self.strokeValueRed, self.strokeValueGreen, self.strokeValueBlue, self.strokeValueAlpha); // white
CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 0.1f); // translucent white
CGContextSetLineWidth(context, self.lineWidth);
CGContextFillEllipseInRect(context, circleRect);
CGContextStrokeEllipseInRect(context, circleRect);
// Draw progress
CGPoint center = CGPointMake(allRect.size.width/2, allRect.size.height/2);
CGFloat radius = (allRect.size.width - 4)/2;
CGFloat startAngle = - ((float)M_PI/2); // 90 degrees
CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle;
CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // white
CGContextMoveToPoint(context, center.x, center.y);
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextClosePath(context);
CGContextFillPath(context);
}
[编辑#2]
我改变了代码删除所有的填充引用,但现在它不是画什么:(任何想法?
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGRect allRect = self.bounds;
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw background
CGContextSetRGBStrokeColor(context, self.strokeValueRed, self.strokeValueGreen, self.strokeValueBlue, self.strokeValueAlpha); // white
CGContextSetLineWidth(context, 5);
// Draw progress
CGPoint center = CGPointMake(allRect.size.width/2, allRect.size.height/2);
CGFloat radius = (allRect.size.width - 4)/2;
CGFloat startAngle = - ((float)M_PI/2); // 90 degrees
CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle;
CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0);
CGContextStrokePath(context);
}
[编辑#3]解决方案
对我感觉就像一个正确的dickhead!问题是,笔画颜色值没有初始化,意味着线正在绘制,但显然看不到它!!
感谢您的帮助! – bennythemink