简体   繁体   English

UIView transitionFromView动画翻转具有不同的视图大小?

[英]UIView transitionFromView animate flip with different view sizes?

I have a small view and a big one, and want to flip animate between them, as a selection toggle (on a different button). 我有一个小视图和一个大视图,并希望在它们之间翻转动画,作为选择切换(在另一个按钮上)。 I am using the UIView transition block method, and the flip is actually happening correctly. 我正在使用UIView过渡块方法,并且翻转实际上是正确发生的。

However, during the transition, the larger view is cropped and cut down to the exact same size as the smaller one. 但是,在过渡期间,将放大较大的视图并将其缩小到与较小的视图完全相同的大小。 On complete it again goes back to full size, but with a jerk. 完成后,它又回到了原尺寸,但是有点混蛋。 So while victory is so close, I've been playing with different permutations and combinations for the past 5 hours with no luck in smooth transition. 因此,尽管胜利是如此接近,但在过去的5个小时里,我一直在使用不同的排列和组合进行游戏,但没有顺利过渡的运气。

Is it really not possible to transition flip between 2 views of different sizes? 真的不可能在两个大小不同的视图之间切换吗? Someone please help! 有人请帮忙!

My one line transition is below. 我的一行过渡如下。 ivCategory is the small view, with CGSize = (40.0f,48.0f) . ivCategory是小视图, CGSize = (40.0f,48.0f) ivAvatar is the large view, with CGSize = (124.0f,318.0f) . ivAvatar是大视图, CGSize = (124.0f,318.0f) Both are UIImageView views. 两者都是UIImageView视图。 Both already exist, added as subviews in the same parent view. 两者都已经存在,并作为子视图添加到同一父视图中。

[UIView transitionFromView:self.ivCategory 
                    toView:self.ivAvatar
                  duration:1
                   options:UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionShowHideTransitionViews
                completion:^(BOOL finished){}];

Put the smaller view into a container view that's the same size as the larger view. 将较小的视图放入与较大的视图相同大小的容器视图中。 The switch the larger view and the container view with your flip animation. 使用翻转动画切换更大的视图和容器视图。 You might be able to set opaque to NO and install a clear background color on the container view to get it to not show up at all. 您可能可以将opaque设置为NO,并在容器视图上安装透明的背景色,以使其完全不显示。 You'd have to test that on the lowest-end device you plan to support, though, since animating non-opaque views with transparency can be slow. 但是,您必须在计划支持的最低端设备上进行测试,因为使用透明性对非透明视图进行动画处理可能会很慢。 (We're only supporting the 3Gs and above.) (我们仅支持3G及更高版本。)

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

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