MBProgressHUD-Determinated Mode重绘代码.

来源:互联网 发布:开源cms系统 php商城 编辑:程序博客网 时间:2024/06/06 00:14
- (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];}