【发布时间】:2012-01-29 06:28:24
【问题描述】:
比如我用横屏状态的动画,持续时间是5.0s,从状态A到B;在 5.0 年代中期,我可能会将 iPad 从横向旋转到纵向。我希望动画停止并在我旋转后将 UI 状态设置为 C。
我不确定我的问题是否清楚。 我该怎么做?
我的动画代码:
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration x:(NSNumber*)dx y:(NSNumber*)dy
{
// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
// The transform matrix
float fx = [dx floatValue];
float fy = [dy floatValue];
CGAffineTransform transform = CGAffineTransformMakeTranslation(fx, fy);
//CGAffineTransform transform = CGAffineTransformMakeRotation(0.4);
//CGAffineTransform transform = CGAffineTransformMakeScale(2.0, 2.0);
image.transform = transform;
// Commit the changes
[UIView commitAnimations];
}
【问题讨论】:
-
我编辑了您的问题以删除标签和单词 Xcode,因为您的问题与 Xcode 无关,而与 iOS 无关。您能否再次编辑您自己的问题以添加一些代码来向我们展示您是如何制作动画的?有几种方法可以制作动画,因此任何有用的答案都取决于您的实现。谢谢!
标签: ios animation core-animation rotation