【发布时间】:2014-02-10 11:40:37
【问题描述】:
我有两张图片 mosha1 和 mosha2。我通过 UIView 动画将它们从某个位置移动到另一个点 (206,89)。现在我想如果用户在移动时触摸任何图像,该图像的移动就会停在那里。所以我设置了停止动画运动的代码:
[mosha1.layer removeAllAnimations];
这个方法调用停止了图像的移动,但是它显示在点 (206,89) 上。但它应该出现在用户触摸它的确切位置。如何解决这个问题?
UIView 动画方法:
-(void)moshaMoveUp: (UIImageView *)mosha {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
mosha.center = CGPointMake(206, 89);
[UIView commitAnimations];
}
【问题讨论】:
-
这是一种非常古老的动画制作方法,在 iOS 4.0 之后不鼓励使用。阅读文档。改用基于块的动画。
标签: ios iphone objective-c ios7 uiviewanimation