CATransition怎么夹到的UIView的界限? [英] CATransition how to clip to bounds of UIView?

查看:155
本文介绍了CATransition怎么夹到的UIView的界限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CATransition滑动的UIView子视图。但问题在于,CATransition总是出现在整个屏幕。它看起来像一个烂摊子,因为我已经在另一个窗口的UI元素,而过渡之成为重叠。我如何通过UIView的框架限制的过渡帧?我想我UIView的clipToBounds设置为YES。其实这并没有帮助。

I'm using CATransition to slide subviews of UIView. But the problem is that the CATransition always appears in whole screen. And it looks like a mess because I have another UI elements in window that become overlapped while transitioning. How can I restrict frame of transition by UIView frame? I tried to set clipToBounds of my UIView to YES. Actually it doesn't help.

推荐答案

我真的不100%肯定这一点,但我认为你是错的CATransition申请到的全部的屏幕。它适用于您添加动画到视图。

I'm not really 100% sure about this, but I think you're wrong about CATransition applying to the whole screen. It applies to the view you add the animation to.

的想法是,你申请过渡到的的你真的想转型的看法。所以说,你有以下的结构。

The idea is that you apply the transition to the parent of the view you actually want to transition. So say you have the following structure.


  • 的UIViewController


    • 视图(UIViewController中的主视图)

      • 查看您正在转变

      您需要做的就是添加的主要的UIViewController观点和你实际的目标视图之间的持有或容器的看法,这样它看起来像这样:

      What you need to do is add a "holding" or "container" view between the main UIViewController view and your actual targeted view, such that it looks like this:


      • 的UIViewController


        • 视图(UIViewController中的主视图)

          • 容器查看< - 在这里应用过渡

            • 查看您正在转变

            应用您的容器视图过渡,你就可以将它夹,如果你想。如果仍然超出范围,然后尝试在包含在视图打开clipsToBounds,或该层的masksToBounds财产

            Apply your transition to the container view and you'll be able to clip it, if you want. If it still goes out of bounds, then try turning on clipsToBounds on the containing view, or the layer's masksToBounds property

            这篇关于CATransition怎么夹到的UIView的界限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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