我在使用UIImageView時遇到擺動動畫基礎重力影響的麻煩。任何哥們能幫我從這個麻煩中解脫出來嗎?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
在此先感謝。
我已經試過幾乎所有的動畫。但我想我需要應用引力的數學公式.. – 2013-02-27 04:38:11