0

所以我有一个应用程序,一旦应用程序打开,我就会为它的一些 UI 元素设置动画。这些动画是使用简单的 UIView 动画完成的。下面是 viewDidLoad 部分的示例

    //animate settings in the frame
    CGRect settingsFrame = settingsView.frame;
    settingsFrame.origin.x = -104;
    settingsFrame.origin.y = 457;
    settingsView.frame = settingsFrame;

    //animate about in the frame
    CGRect aboutFrame = aboutView.frame;
    aboutFrame.origin.x = -104;
    aboutFrame.origin.y = 457;
    aboutView.frame = aboutFrame;

这是一个被调用的相应方法部分。

CGRect settingsFrame = settingsView.frame;
settingsFrame.origin.x = 0; // new x coordinate
settingsFrame.origin.y = 457; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
settingsView.frame = settingsFrame;

CGRect aboutFrame = aboutView.frame;
aboutFrame.origin.x = 104; // new x coordinate
aboutFrame.origin.y = 457; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
aboutView.frame = aboutFrame;

还有 4 组匹配的代码来完成动画。我的问题是,每当启用 viewDidLoad 部分(未注释掉)时,它都会减慢我的应用程序中向 xib 的其他转换。你们知道我如何保持这些动画但没有缓慢的过渡吗?

除此之外,我应该说这是在 iOS 7 和 Xcode 5 开发者预览版上开发的,所以我不排除一个错误......

4

1 回答 1

0

您忘记在动画块的末尾添加 commitAnimations... 执行以下操作,您的问题将得到解决。

CGRect settingsFrame = settingsView.frame;
settingsFrame.origin.x = 0; // new x coordinate
settingsFrame.origin.y = 457; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
settingsView.frame = settingsFrame;
**[UIView commitAnimations];**

CGRect aboutFrame = aboutView.frame;
aboutFrame.origin.x = 104; // new x coordinate
aboutFrame.origin.y = 457; // new y coordinate
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
aboutView.frame = aboutFrame;
**[UIView commitAnimations];**
于 2013-08-06T10:47:31.943 回答