我使用垂直位于UIBezierPath和CAShapeLayer的圆圈绘制了一条线。我想将线条与动画一起旋转到90度,以便在动画之后线条水平放置。我尝试了很多动画解决方案,但是线条不会沿着具有相同中心点的圆圈旋转,而是离开圆圈。我需要在不改变中心点的情况下用动画旋转线条。
UIBezierPath *CirclePath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(_width*4, _height*4) radius: (_width*3.5)
startAngle:0 endAngle: (2*3.14) clockwise:YES];
CAShapeLayer *Circlelayer = [CAShapeLayer layer];
Circlelayer.path = [CirclePath CGPath];
Circlelayer.strokeColor = [[UIColor orangeColor]CGColor];
Circlelayer.lineWidth = _width*0.6;
Circlelayer.fillColor = [[UIColor clearColor] CGColor];
[self.layer addSublayer:Circlelayer];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(_width*4, _height*0.2)];
[path addLineToPoint:CGPointMake(_width*4, _height*7.8)];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.path = [path CGPath];
pathLayer.strokeColor = [[UIColor whiteColor]CGColor];
pathLayer.lineWidth = _width*0.8;
pathLayer.fillColor = [[UIColor whiteColor]CGColor];
[self.layer addSublayer:pathLayer];
提前致谢。
答案 0 :(得分:0)
您可以将pathLayer作为子图层添加到circleLayer中,因此每当应用于circleLayer的转换也会应用于pathLayer。