如何执行没有任何透明度/淡入淡出效果的kCATransitionPush动画 [英] How to perform kCATransitionPush animation without any transparency / fade effects

查看:138
本文介绍了如何执行没有任何透明度/淡入淡出效果的kCATransitionPush动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

我正在尝试复制[UIViewController presentModalViewController:animated:]执行的从底部向上滑动动画,但是没有调用它,因为我

I'm trying to duplicate the "slide up from the bottom" animation that [UIViewController presentModalViewController:animated:] performs but without calling it because I don't want a modal view.

下面的核心动画代码非常接近,但是在此期间似乎正在更改视图的透明度值。在动画开始时,您可以部分向上滑动视图。在动画的中间/结尾,我们滑过的视图是完全透明的,因此我们可以在其后面看到。我希望两者在此动画过程中都保持完全不透明。

The below core animation code comes very close but appears to be changing transparency values of the views during it. At the start of the animation you can partially see through the view sliding up. By the middle/end of the animation the view we are sliding over is fully transparent so we can see behind it. I'd like both to remain fully opaque during this animation.

关于如何在此代码中停止透明度更改或获取滑动动画的任何想法,我

Any ideas on how to stop transparency changes in this code or to otherwise get the "slide up animation" I am looking for without requiring a modal view?

UIViewController *nextViewController = [[UIViewController alloc] autorelease];
nextViewController.view.backgroundColor = [UIColor redColor];  
CATransition *animation = [CATransition animation];
animation.duration = 3.5;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;  
[self.navigationController pushViewController:nextViewController animated:NO];
[self.navigationController.view.layer addAnimation:animation forKey:nil];


推荐答案

最简单的方法是简单地使用UIView beginAnimations / commitAnimations块。您可以通过查看文档来调整持续时间和曲线。

The simplest method is to simply use UIView beginAnimations/commitAnimations block. You can adjust the duration and curve by reviewing the docs.

{   
    // Adjust for orientation as necessary.
    view.frame = CGRectMake(0,
                        -480, 
                        320,
                        480);

    [UIView beginAnimations:nil context:nil];

    view.frame = CGRectMake(view.frame.origin.x,
                        0, 
                        view.frame.size.width,
                        view.frame.size.height);

    [UIView commitAnimations];
}

此处的文档:

http://developer.apple .com / library / ios /#documentation / uikit / reference / UIView_Class / UIView / UIView.html

这篇关于如何执行没有任何透明度/淡入淡出效果的kCATransitionPush动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆