iPhone页面 curl 过渡动画

标签 iphone objective-c uiimageview

我正在尝试在窗口中使用 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 并没有发生。不过它确实会褪色。

我不确定这是否与语法或 SplashImageUIWindow 中的 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/

相关文章:

ios - 为处于等待审核状态的 iPhone 应用程序添加屏幕截图

javascript - 为什么当我更改它们的源属性时我的图像没有改变 -JQuery Mobile & Phone Gap

IOS - 在 Cocos2d 中使用 CCCallBlock,小行星游戏

objective-c - 如何独立于 CALayer 的边界缩放 CALayer 的图像

ios - 使用计时器逐渐旋转 UIImageView

ios - 获取图像后从其 imageView 刷新 UITableViewCell 布局

ios - 使用引用条码字符串生成 UPC-A 条码图像

iphone - 在iphone中通过sqlite从数据库中检索数据

objective-c - KVC一致性测试

iphone - 缩放后如何在 imageView 中调整图像大小?