相关疑难解决方法(0)

将圆角应用于使用UIBezierPath创建的弧

我正在使用UIBezierPath创建的循环进度条.进度条如下图所示:

在此输入图像描述

我的问题是:如何使圆弧的边缘变圆而不是矩形?

我用来绘制弧线的代码如下:

 // Draw the arc with bezier path
        int radius = 100;

        arc = [CAShapeLayer layer];
        arc.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100, 50) radius:radius startAngle:M_PI endAngle:M_PI/150 clockwise:YES].CGPath;
        arc.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
                                    CGRectGetMidY(self.view.frame)-radius);
        arc.fillColor = [UIColor clearColor].CGColor;
        arc.strokeColor = [UIColor purpleColor].CGColor;
        arc.cornerRadius = 0.5;
        arc.lineWidth = 6;

        [self.view.layer addSublayer:arc];

        // Animation of the progress bar
        drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
        drawAnimation.duration            = 5.0; // "animate over 10 seconds or so.."
        drawAnimation.repeatCount         = 1.0;  // Animate only once..
        drawAnimation.removedOnCompletion = YES;   // Remain stroked …
Run Code Online (Sandbox Code Playgroud)

objective-c uibezierpath

8
推荐指数
2
解决办法
2574
查看次数

标签 统计

objective-c ×1

uibezierpath ×1