I am trying to rotate a UIImageView in a round mask (which is set using myImageView.layer.mask). The problem is that whenever I try to rotate the specified UIImageView, the mask rotates with it. Here is the code.
Mask Setting:
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;
Animation:
[UIView animateWithDuration:kRotationTime animations:^(void){ myImageView.transform = CGAffineTransformMakeRotation(angle); }];
And that, in principle, everything is there. UIImageView rotating around its own center in a fixed position circular mask is the desired effect. There may be another way to structure the hierarchy of views so that myImageView and mask are siblings, but I have no luck with this route.
source share