UIView transitionFromView 动画翻转具有不同的视图大小?
我有一个小视图和一个大视图,并且想要在它们之间翻转动画,作为选择切换(在不同的按钮上)。我正在使用 UIView 转换块方法,并且翻转实际上正确发生。
然而,在过渡过程中,较大的视图会被裁剪并缩小到与较小的视图完全相同的尺寸。完成后,它会再次恢复到完整尺寸,但会出现抖动。因此,虽然胜利如此接近,但过去 5 小时我一直在玩不同的排列和组合,但没有顺利过渡的运气。
难道真的不可能在两个不同尺寸的视图之间进行翻转翻转吗?请有人帮忙!
我的一行转换如下。 ivCategory
是小视图,其中 CGSize = (40.0f,48.0f)
。 ivAvatar 是大视图,CGSize = (124.0f,318.0f)
。两者都是 UIImageView 视图。两者都已存在,作为子视图添加到同一父视图中。
[UIView transitionFromView:self.ivCategory
toView:self.ivAvatar
duration:1
options:UIViewAnimationOptionTransitionFlipFromRight|UIViewAnimationOptionShowHideTransitionViews
completion:^(BOOL finished){}];
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.
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.
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)
. ivAvatar is the large view, with CGSize = (124.0f,318.0f)
. Both are UIImageView
views. 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){}];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将较小的视图放入与较大视图大小相同的容器视图中。使用翻转动画切换较大视图和容器视图。您也许可以将不透明设置为“否”,并在容器视图上安装清晰的背景颜色,以使其根本不显示。不过,您必须在计划支持的最低端设备上进行测试,因为使用透明度对非不透明视图进行动画处理可能会很慢。 (我们仅支持 3G 及以上。)
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. 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.)