我正在尝试在窗口中使用 UIImageView
发起页面 curl 转换。此代码在我的主要初始化方法中:
[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];
图像动画位置和大小但没有 curl 。如果我取消对 removeFromSuperView
的注释,它就会立即消失。有什么想法吗?
更新:
已经更改了代码,因此它使用 Lars 非常巧妙的方式来触发动画并包括动画和回调 ...
[UIView animateWithDuration:1.5
delay:delay
options: UIViewAnimationTransitionCurlUp
animations:^{splashImage.alpha = 0;}
completion:^(BOOL finished){[splashImage removeFromSuperview];}
];
不幸的是,页面 curl 并没有发生。不过它确实会褪色。
我不确定这是否与语法或 SplashImage
是 UIWindow
中的 UIImageView
类有关> 我的主要观点的对象。也许它需要在 UIView
中才能创建转换。
最佳答案
尝试这样的事情:
[UIView transitionWithView:splashImage
duration:1.5
options: UIViewAnimationOptionTransitionCurlUp
animations^{
splashImage.frame = CGRectMake(-320, 0, 10, 10);
}
completion:^(BOOL finished){
[splashImage removeFromSuperview];
//animCompleteHandlerCode..
}
];
未经测试,可能存在一些语法错误,但请尝试一下!
或者这样更好:
[UIView animateWithDuration:1.5
delay:delay
options: UIViewAnimationOptionTransitionCurlUp
animations^{
splashImage.frame = CGRectMake(-320, 0, 10, 10);
}
completion:^(BOOL finished){
[splashImage removeFromSuperview];
//animCompleteHandlerCode..
}
];
关于iPhone页面 curl 过渡动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3665961/