我正在尝试在窗口中使用UIImageView
实现页面翻页过渡效果。以下代码位于我的主初始化方法中:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelay:delay];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDidStopSelector:@selector(animCompleteHandler:finished:context:)];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:splashImage cache:YES];
splashImage.frame = CGRectMake(-320, 0, 10, 10);
//[splashImage removeFromSuperview];
[UIView commitAnimations];
这张图片可以动态改变位置和大小,但不能卷曲。如果取消注释removeFromSuperView
,则会立即消失。有任何想法吗?
更新:
已更改代码,使用Lars的非常简洁的方式触发动画并包括动画和回调...
[UIView animateWithDuration:1.5
delay:delay
options: UIViewAnimationTransitionCurlUp
animations:^{splashImage.alpha = 0;}
completion:^(BOOL finished){[splashImage removeFromSuperview];}
];
很遗憾,页面翻页效果不会发生。但是它会渐变。
我不确定这是否与语法或者SplashImage
是UIWindow
对象中的UIImageView
类有关。也许它需要在UIView
中才能创建转换效果。