【问题标题】:mixed with other UIViewAnimations in a block与块中的其他 UIViewAnimations 混合
【发布时间】:2011-01-12 18:53:25
【问题描述】:

我试图在 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){}];
                    }
                }];

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

提前致谢。

【问题讨论】:

    标签: ipad ios uianimation


    【解决方案1】:

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

    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-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    相关资源
    最近更新 更多