简体   繁体   English

如何在另一个视图iOS上垂直翻转视图?

[英]How to flip the view vertically on another view iOS?

I'm developing an app which contained stack of views and i want that when the user swipes down on a image view this flip and shows another view.Its working but while its flipping vertically it merging with below lying view and showing another view. 我正在开发一个包含视图堆栈的应用程序,我希望当用户在图像视图上向下滑动时显示此翻转并显示另一个视图。它可以正常工作,但在垂直翻转时会与下面的视图合并并显示另一个视图。

Please go through the link , one will comes to know: https://dribbble.com/shots/1667024-Events-deck-animation 请通过链接,您将知道: https : //dribbble.com/shots/1667024-Events-deck-animation

In above link,in animation after swipe left and right ,the user will down vertically without merging with below lying views.Please any help how to implement this vertical flip animation as shown in the mentioned link. 在上面的链接中,在向左和向右滑动后的动画中,用户将垂直向下滑动,而不会与下面的躺卧视图合并。请帮助您实现上述链接中所示的垂直翻转动画。

I am using the following code to flip veertically for single layer: 我正在使用以下代码垂直翻转单层:

float duration = 1.0f;
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animation.delegate = self;
animation.fromValue = [NSNumber numberWithDouble:-0.0f * M_PI];
animation.toValue = [NSNumber numberWithDouble:-1.0f * M_PI];
animation.duration = duration;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeRemoved;
animation.repeatCount =1;
animation.beginTime = CACurrentMediaTime();
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[photo.layer addAnimation:animation forKey:@"rotationX"];
photo.layer.position = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds));

Please any one knowsshare it ,I need to implement this animation. 请任何人知道分享它,我需要实现此动画。

Try using UiView's transitionFromView method with UIViewAnimationOptionTransitionFlipFromBottom or UIViewAnimationOptionTransitionFlipFromTop for implementing animations on UIView than view's layer. 尝试将UiView的transitionFromView方法与UIViewAnimationOptionTransitionFlipFromBottomUIViewAnimationOptionTransitionFlipFromTop以在UIView而非视图层上实现动画。

Like: 喜欢:

[UIView transitionFromView:viewToReplace
                    toView:replacementView
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromTop
                completion:nil];

Add this call in the swipe gesture selector method of the viewToReplace viewToReplace的滑动手势选择器方法中添加此调用

For more see this link: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/doc/uid/TP40006816-CH3-SW105 有关更多信息,请参见以下链接: https : //developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/doc/uid/TP40006816-CH3-SW105

EDIT : May be This will work for you. 编辑 :可能这将为您工作。

// Consider flipView as the view that need to flip vertical 
[UIView transitionWithView:flipView
                      duration:1
                       options:UIViewAnimationOptionTransitionFlipFromTop
                    animations:^{
                        // flipView.backgroundColor = [UIColor greenColor];
                        // update to be done with flip
                       } completion:nil];

只要尝试在代码的最后一行添加注释,您的视图就会在同一位置进行动画处理或垂直翻转,而无需与基础视图合并。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM