Permalink
Browse files

TWPieProgressView improvements

  • Loading branch information...
1 parent 5f677fd commit b3fa023d2fd7035f114ebdeaa428d630e2977ee9 @soffes soffes committed Apr 23, 2010
Showing with 13 additions and 12 deletions.
  1. +13 −12 TWToolkit/TWPieProgressView.m
@@ -67,18 +67,19 @@ - (void)drawRect:(CGRect)rect {
// Fill
[_pieFillColor set];
- CGContextSetLineWidth(context, 1.0);
- CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
- CGFloat radius = center.y;
- CGFloat angle = DEGREES_TO_RADIANS((360.0 * _progress) + kAngleOffset);
- CGPoint p[3] = {
- CGPointMake(center.x, 0.0),
- center,
- CGPointMake(center.x + radius * cos(angle), center.y + radius * sin(angle))
- };
- CGContextAddLines(context, p, sizeof(p)/sizeof(p[0]));
- CGContextAddArc(context, center.x, center.y, radius, DEGREES_TO_RADIANS(kAngleOffset), angle, false);
- CGContextDrawPath(context, kCGPathEOFill);
+ if (_progress > 0.0) {
+ CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
+ CGFloat radius = center.y;
+ CGFloat angle = DEGREES_TO_RADIANS((360.0 * _progress) + kAngleOffset);
+ CGPoint p[3] = {
+ CGPointMake(center.x, 0.0),
+ center,
+ CGPointMake(center.x + radius * cos(angle), center.y + radius * sin(angle))
+ };
+ CGContextAddLines(context, p, sizeof(p)/sizeof(p[0]));
+ CGContextAddArc(context, center.x, center.y, radius, DEGREES_TO_RADIANS(kAngleOffset), angle, false);
+ CGContextDrawPath(context, kCGPathEOFill);
+ }
// Border
[_pieBorderColor set];

0 comments on commit b3fa023

Please sign in to comment.