- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat lineWidth = 2.f;
CGRect allRect = self.bounds;
CGRect circleRect = CGRectInset(allRect, lineWidth/2.f, lineWidth/2.f);
CGPoint center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));
[[UIColor yellowColor] setStroke];
// [[UIColor redColor] setFill];
CGContextSetLineWidth(context, lineWidth);
CGContextStrokeEllipseInRect(context, circleRect);
// 90 degrees
CGFloat startAngle = - ((float)M_PI / 2.f);
UIBezierPath *processPath = [UIBezierPath bezierPath];
processPath.lineCapStyle = kCGLineCapButt;
processPath.lineWidth = lineWidth * 2.f;
CGFloat radius = (CGRectGetWidth(self.bounds) / 2.f) - (processPath.lineWidth / 2.f);
CGFloat endAngle = (0.01 * 2.f * (float)M_PI) + startAngle;
[processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];
// Ensure that we don't get color overlaping when _progressTintColor alpha < 1.f.
CGContextSetBlendMode(context, kCGBlendModeCopy);
[[UIColor redColor] set];
[processPath stroke];
}
MBProgressHUD-Determinated Mode重绘代码.
最新推荐文章于 2017-06-13 09:45:45 发布