0

我已阅读苹果文档:http: //developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html#//apple_ref/doc/uid/TP40009503-CH6-SW1

对于 iOS3.0 及更早版本,使用这个:

方法1:

[UIView beginAnimations:@"ShowHideView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
...

新的 iOS4 可以做到这一点:

方法2:

[UIView animateWithDuration:1.0 animations:^{
    firstView.alpha = 0.0;
    secondView.alpha = 1.0;
}];

Q1。我想知道的是,在早期的方法中,他们在 beginAnimations 中有这个“ShowHideView”,那个方法是内置的吗?

Q2。beginAnimations 中还有其他内置动画方法吗?如果是,我在哪里可以找到所有这些方法?

Q3。最后,我可以在后面的方法(method2)调用中使用这些方法吗?

4

2 回答 2

0

您可以在UIView 类参考中获得所有问题的答案。

Q1ShowHideView正如你所拥有的,它根本不是一种方法。它只是一个“应用程序提供的动画标识符”。实际上,您不需要它。当我使用这种方法时,我只是使用NULL而不是在那里提供标识符。

Q2:你没有在beginAnimations:context:通话中设置动画。你甚至可以通过调用setAnimationCurve. 您可以从此typedef设置动画。

Q3:同样,您也没有在animateWithDuration:animations:调用中声明动画类型。setAnimationCurve:在该示例中也可以使用它。

于 2011-06-10T03:49:27.713 回答
0

块的好处是能够使用[UIView animateWithDuration:animations:completion:]选择器嵌套动画(几乎在队列中)。您可以在块内嵌套对该方法的另一个调用,finished如下所示:

[UIView animateWithDuration:1.0 animations:^{  
   // your first animations
} completion:^(BOOL finished) {
   [UIView animateWithDuration:1.0 animations:^{
         // more animations
     } completion:^(BOOL finished) {
         // ... maybe even more
     }]
 }]

我在我的代码中滥用了它,发现它比使用 beginAnimations/commitAnimations 代码容易得多。而且,随着 iOS 5 的临近,需要支持 iOS 3.x 的日子正在逐渐消失。

于 2011-06-10T04:01:46.303 回答