nil*_*nil 54
除了esqew的方法(在iOS 4之前可用,所以你可能应该使用它,如果你不打算将你的工作限制在iOS 4),还有[UIView animateWithDuration:animations:],它允许你在一个块中做动画.例如:
[UIView animateWithDuration:3.0 animations:^(void) {
image1.alpha = 0;
image2.alpha = 1;
}];
Run Code Online (Sandbox Code Playgroud)
相当简单,但同样,这只适用于iOS 4,所以请记住这一点.
Cha*_*irA 11
其他解决方案,淡入和淡出:
//Disappear
[UIView animateWithDuration:1.0 animations:^(void) {
SplashImage.alpha = 1;
SplashImage.alpha = 0;
}
completion:^(BOOL finished){
//Appear
[UIView animateWithDuration:1.0 animations:^(void) {
[SplashImage setImage:[UIImage imageNamed:sImageName]];
SplashImage.alpha = 0;
SplashImage.alpha = 1;
}];
}];
Run Code Online (Sandbox Code Playgroud)
实际上这非常简单.将以下代码放在要进行动画的位置:
[UIView beginAnimations:NULL context:NULL];
[UIView setAnimationDuration:3.0]; // you can set this to whatever you like
/* put animations to be executed here, for example: */
[image1 setAlpha:0];
[image2 setAlpha:1];
/* end animations to be executed */
[UIView commitAnimations]; // execute the animations listed above
Run Code Online (Sandbox Code Playgroud)
您可以在本文档中阅读有关这些方法的更多信息.
如果您想使用您在此问题的评论中提到的结构:
[UIView beginAnimations:NULL context:NULL];
[UIView setAnimationDuration:3.0]; // you can set this to whatever you like
/* put animations to be executed here, for example: */
[[introAnimation objectAtIndex:0] setAlpha:0];
[[introAnimation objectAtIndex:1] setAlpha:1];
/* end animations to be executed */
[UIView commitAnimations]; // execute the animations listed above
Run Code Online (Sandbox Code Playgroud)
... 应该管用.