Tôi muốn vẽ một đường cong cho đến khi nó quay tròn đầy đủ và tham gia để trở thành một vòng tròn hoàn chỉnh, chỉ đường viền hình tròn, không được lấp đầy. Điều này phải được làm động trong một vài giây.iPhone: Vẽ một đường cong cho đến khi nó trở thành hình động vòng tròn
Có ai có thể chỉ cho tôi đúng hướng không? Tôi đã yêu cầu một số similar question cho điều này nhưng tôi đã diễn đạt nó không chính xác nên mọi người đều có một thời gian khó hiểu ý tôi và do đó nó đã bị lạc trong biển các câu hỏi.
Nhiều Nhờ sự giúp đỡ
[sửa]
Tôi hiện đang phụ classing UIView và drawRect trọng. Tôi tìm thấy mã để vẽ một vòng tròn đầy nhưng tôi chỉ yêu cầu đột quỵ.
- (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);
}
[sửa # 2]
tôi đã thay đổi mã để loại bỏ tất cả các tài liệu tham khảo điền nhưng bây giờ nó bất cứ điều gì không vẽ :(bất kỳ ý tưởng?
- (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);
}
[sửa # 3] Giải pháp
Tôi cảm thấy giống như một dickhead đúng! Vấn đề là các giá trị màu sắc đột quỵ không được khởi tạo có nghĩa là dòng đã được rút ra nhưng rõ ràng là không thể nhìn thấy nó !!
cảm ơn sự giúp đỡ của bạn! – bennythemink