CGPoint oldOrigin = self.bellImgV.frame.origin;
// 围绕旋转的点
self.bellImgV.layer.anchorPoint = CGPointMake(0.3, 0);
CGPoint newOrigin = self.bellImgV.frame.origin;
CGPoint transition;
transition.x = newOrigin.x - oldOrigin.x;
transition.y = newOrigin.y - oldOrigin.y;
self.bellImgV.center = CGPointMake (self.bellImgV.center.x - transition.x, self.bellImgV.center.y - transition.y);
[self.bellImgV.layer removeAllAnimations];
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
// 旋转角度
rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI*0.15];
rotationAnimation.duration = 1;
rotationAnimation.repeatCount = HUGE_VALF;
// 动画结束时是否执行逆动画
rotationAnimation.autoreverses = YES;
[self.bellImgV.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
网友评论