0

我正在尝试动态制作高分辨率图形。不幸的是,当我制作弧线时,它们看起来真的很模糊。

为什么这么模糊?

这是我的代码

- (void)drawRect:(CGRect)rect
{
    [super drawRect:rect];

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGRect bounds = [self bounds];
    CGPoint center = CGPointMake(bounds.size.width / 2.0, bounds.size.height / 2.0);

    CGFloat lineWidth = 30.0;
    CGFloat innerRadius = (bounds.size.width / 2.0) - lineWidth;
    CGFloat outerRadius = innerRadius + lineWidth;
    CGFloat startAngle = -((float)M_PI / 2.0);
    CGFloat endAngle = ((self.percent / 100.0) * 2 * (float)M_PI) + startAngle;

    UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath];
    processBackgroundPath.lineWidth = lineWidth;
    CGFloat radius = (self.bounds.size.width - lineWidth) / 2.0;
    CGFloat fullAngle = (2.0 * (float)M_PI) + startAngle;
    [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:fullAngle clockwise:YES];
    [[UIColor whiteColor] set];
    [processBackgroundPath stroke];

    CGMutablePathRef progressPath = CGPathCreateMutable();
    CGPathMoveToPoint(progressPath, NULL, center.x, center.y - innerRadius);
    CGPathAddArc(progressPath, NULL, center.x, center.y, innerRadius, startAngle, endAngle, YES);
    CGPathAddArc(progressPath, NULL, center.x, center.y, outerRadius, endAngle, startAngle, NO);
    CGPathCloseSubpath(progressPath);

    UIColor *aColor = [UIColor colorWithRed:0.941 green:0.776 blue:0.216 alpha:1.0];
    [aColor setFill];
    CGContextAddPath(context, progressPath);
    CGContextFillPath(context);

    CGPathRelease(progressPath);
}

我需要做什么才能使甜甜圈更脆?

4

0 回答 0