我在 UIImageView 上应用钟摆动画基础重力效果时遇到了麻烦。有没有朋友可以帮我摆脱这个麻烦??
我试过下面的源代码。但在那个万有引力是不适用的。
- (void)swingPendulum {
pendulum.layer.anchorPoint = CGPointMake(0.5,0);
[pendulum.layer setTransform:CATransform3DMakeRotation(-M_PI*3/4, 0, 0, 1)];
CABasicAnimation *needleAnim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
needleAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
needleAnim.duration = 1;
needleAnim.repeatCount = 5;
needleAnim.autoreverses = YES;
// Setting fillMode means that, once the animation finishes, the needle stays in its end position.
needleAnim.fillMode = kCAFillModeForwards;
needleAnim.removedOnCompletion = YES;
needleAnim.toValue = [NSNumber numberWithFloat:M_PI*3/4];
[pendulum.layer addAnimation:needleAnim forKey:nil];
}
实际上我们需要像...这样的动画
看看这个:http ://blog.ruben-martins.co.uk/2010/02/maya-tutorials-pendulum-animation.html
提前致谢。