[英]How can I create a transition between two subview iOS?
I have a problem when I want to create a transition between to views inside a container view in iOS application.当我想在 iOS 应用程序中的容器视图内创建视图之间的转换时,我遇到了问题。 I want to create an animation that makes my first view goes out sliding to the left and the second coming from the right (like switching between photos, a sort of push in Navigation Controller).
我想创建一个 animation 使我的第一个视图向左滑动,第二个从右侧滑动(例如在照片之间切换,导航控制器中的一种推送)。 I created my animation but the problem is that my subview does not disappear once reached the border of my container view but when it reaches the edge of my screen.
我创建了我的 animation 但问题是我的子视图在到达我的容器视图的边界时并没有消失,但是当它到达我的屏幕边缘时。
I used this code:我使用了这段代码:
CATransition *transition = [CATransition animation];
transition.duration = animationTime;
transition.type = kCATransitionPush;
transition.subtype = transationSubtype;
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
transition.removedOnCompletion = YES;
[view.layer addAnimation:transition forKey:nil];
As visible in the image the red square goes out from the screen and not from its container and also the green comes inside from the screen edge and not from the container view edge.如图所示,红色方块从屏幕而不是从其容器中消失,绿色从屏幕边缘进入内部,而不是从容器视图边缘进入。 I want instead that the animation ends when reaches the container view edge.
我希望 animation 在到达容器视图边缘时结束。
I tried anything but I was not able to find something useful.我尝试了任何东西,但找不到有用的东西。
Try to set clipsToBounds property of the container view to YES尝试将容器视图的 clipsToBounds 属性设置为 YES
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.