与块中的其他 UIViewAnimations 混合

发布于 2024-10-12 03:52:49 字数 827 浏览 6 评论 0原文

我试图在 iPad 上实现类似 iBook 商店的功能。 当您点击书籍封面时,它会以一种流畅的动作翻转和缩放,从书籍封面到空白背景,然后加载内容。

我尝试了不同的方法,首先翻转,然后缩放,我尝试将 transitionFromView 包装在 animateWithDuration 块内,但我无法让它看起来正确。它要么先做一个,然后再做另一个,或者在最后一种情况下先做一个,然后“flickr”,然后什么都不做。

[UIView transitionFromView:fromView
                    toView:toView
                  duration:0.8
                   options:UIViewAnimationOptionTransitionFlipFromRight
                completion:^(BOOL finished) {
                    if (finished) {
                            [UIView animateWithDuration:0.4
                                animations:^{[fromView setFrame:originFrame];}
                                completion:^(BOOL finished){}];
                    }
                }];

毫无疑问,块非常适合动画! 但我怎样才能同时翻转和缩放呢?

提前致谢。

I was trying to implement something resembling the iBook store on iPad.
When you tap on a book cover it will flip and scale in one fluid motion, from the book cover to an empty background - which then loads the content.

I have tried different approaches, first flipping, then scaling, I tried wrapping the transitionFromView inside the animateWithDuration block, but i can't get it to look properly. It will either do one then the other, or in the last case do one, then 'flickr' and do nothing.

[UIView transitionFromView:fromView
                    toView:toView
                  duration:0.8
                   options:UIViewAnimationOptionTransitionFlipFromRight
                completion:^(BOOL finished) {
                    if (finished) {
                            [UIView animateWithDuration:0.4
                                animations:^{[fromView setFrame:originFrame];}
                                completion:^(BOOL finished){}];
                    }
                }];

Blocks are great for animations, no doubt!
But how can I both flip and scale at the same time?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

刘备忘录 2024-10-19 03:52:49

我已经能够通过对包含您在其之间切换的视图的视图执行翻转,使用非块动画来产生这种效果。

CGRect endFrame; //The frame of the view after animation
UIView *sview; //The superview containing the first view
UIView *view1; //The first view, to be removed from sview
UIView *view2; //The second view, to be added to sview

view2.frame = view1.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:sview cache:YES];
[view1 removeFromSuperview];
[sview addSubview:view2];
sview.frame = endFrame;
[UIView commitAnimations];

为此,view2 上的自动调整大小蒙版必须可调整宽度和高度的大小。

I have been able to produce this effect using non-block animations by performing the flip on a view containing the views you switch between.

CGRect endFrame; //The frame of the view after animation
UIView *sview; //The superview containing the first view
UIView *view1; //The first view, to be removed from sview
UIView *view2; //The second view, to be added to sview

view2.frame = view1.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:sview cache:YES];
[view1 removeFromSuperview];
[sview addSubview:view2];
sview.frame = endFrame;
[UIView commitAnimations];

For this to work, the autosizing mask on view2 must be resizable in width and height.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文