1

我在 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

提前致谢。

4

1 回答 1

0

如果您有一个顶部空白的图像并从中间开始并且只想旋转它(还没有尝试过):

-(void) doAnimation {

    imgView.transform = CGAffineTransformMakeRotation(-0.7);
    [UIView animateWithDuration:4 delay:0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAutoreverse animations:^{

        imgView.transform = CGAffineTransformMakeRotation(0.7);

    } completion:^{

        [self doAnimation];

    }]
于 2013-02-26T09:57:58.103 回答