反正用2次之间CATransition时取出褪色? [英] Anyway to remove fade when using CATransition between 2 views?

查看:159
本文介绍了反正用2次之间CATransition时取出褪色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做的是从左侧用CATransitions一个自定义动画推英寸在我的正常code我想使用的持续时间 0.3 ,但在下面的例子中我使用 6.0 只是这样我就可以在转换过程中看到的实际问题。

What I'm trying to do is push in from the left side with a custom animation using CATransitions. In my normal code I want to use duration of 0.3, but in the example below I'm using 6.0 just so I can see the actual problem during the transition.

和它是真的很明显,有一个衰落会过渡到新的视图时上。从它变淡未来新的视图的背景色为实际的视图,而被滑动关闭屏幕视图从实际看它的背景颜色变淡。做推动画过渡时,它使一些奇怪的样子。

And it is really obvious that there is a fade going on when transitioning to the new view. The new view coming in fades from it's background color to the actual view, whereas the view that is sliding off screen fades from the actual view to it's background color. It's making for some odd looks when doing the push animation to transition.

下面是code,我使用的过渡。 settingsController 是我试图动画控制器。

Below is the code that I'm using for the transition. settingsController is the controller I'm trying to animate to.

    let transition = CATransition()
    transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    transition.duration = 6.0
    transition.type = kCATransitionPush
    transition.subtype = kCATransitionFromLeft

    self.navigationController?.view.layer.addAnimation(transition, forKey: nil)
    UIView.transitionFromView(self.view, toView: settingsViewController.view, duration: 0, options: UIViewAnimationOptions.TransitionNone, completion: nil)
    self.navigationController?.pushViewController(settingsViewController, animated: false)

和如前所述,实际滑动动画作品,我想它,但是有这种褪色的情况,只是使它看起来不正确。我一直在寻找谷歌和计算器并没有看到一个解决方案贴出来,所以我想知道如果任何人有任何想法如何摆脱这种褪色的,否则即使周围有一部作品模拟这种行为使用户体验看起来我希望它。

And as mentioned, the actual sliding animation works as I want it to, however there is this fade that happens that just makes it not look right . I've been searching google and stackoverflow and have not seen a solution posted, so I'm wondering if anyone has any idea how to get rid of this fade, or even if there is a work around that "simulates" this behavior so the user experience looks as I want it to.

我试过使得这两种观点的背景颜色相同,它仍然看起来不正确的。

I've tried making the background colors of both views the same and it still doesn't look right.

推荐答案

要使用滑动CATransition的常用方法是给过渡视图/层的上海华的剪辑边界(或superlayer的口罩,以边界)。这样,滑动查看/层不是上海华的边界之外可见,我们再也看不到褪色。

The usual way to use a sliding CATransition is to give the transitioning view/layer a superview that clips to bounds (or a superlayer that masks to bounds). That way, the sliding view/layer is not visible outside the superview's bounds, and we never see the fade.

这篇关于反正用2次之间CATransition时取出褪色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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