[英]Swift 3: CAShapeLayer mask not animating for pie chart animation
[英]Keeping CAShapeLayer Mask Static During Animation
我正在尝试在圆形掩码中旋转UIImageView(使用myImageView.layer.mask设置)。 问题是,无论何时我尝试旋转所述UIImageView,掩码都会随之旋转。 这是一些代码。
设置面具:
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(0, - 169)
radius:191
startAngle:0.0
endAngle:2*M_PI
clockwise:YES];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
[shapeLayer setFrame:myImageView.bounds];
[shapeLayer setPath:[path CGPath]];
myImageView.layer.mask = shapeLayer;
动画:
[UIView animateWithDuration:kRotationTime animations:^(void){
myImageView.transform = CGAffineTransformMakeRotation(angle);
}];
而这基本上就是它的全部内容。 UIImageView在固定位置的圆形遮罩内绕其自身中心旋转 - 这是所需的效果。 也许还有另一种方法来构建视图层次结构,以便myImageView和掩码是兄弟姐妹,但我没有运气那条路线。
将图像视图放入另一个普通的UIView超视图中。 在superview上设置图层蒙版。 为图像视图设置动画。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.