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){}];
                    }
                }];

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

提前致谢。

4

1 回答 1

0

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

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 上的自动调整掩码的宽度和高度必须可调整。

于 2011-01-12T20:48:03.380 回答