0
我目前有一个图片在点击一个按钮时有动画效果,但问题是图片在开始动画之前从故事板上的位置跳下。我无法弄清楚它为什么这样做 - 我希望将它从当前位置移出屏幕到右侧。图片在动画之前跳跃
我做错了什么,或只是错过了什么吗?
原始位置:
original http://oi41.tinypic.com/2gwrpfa.jpg
动画的起点:
original http://oi39.tinypic.com/28lezwm.jpg
moveImage触发:
[self moveImage:_cornerCloud duration:3.0
curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
moveImage功能:
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;
// Commit the changes
[UIView commitAnimations];
}
您应该使用'[UIView animateWithDuration:...];' – Fogmeister