【问题标题】:UIViewAnimation Flip not workingUIView 动画翻转不起作用
【发布时间】:2013-02-22 19:28:54
【问题描述】:

在 UIView 子类中我有这个:

self.frontImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"front"]];
self.backImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"back"]];
[self addSubview:self.backImageView];


[UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionTransitionFlipFromLeft
                     animations:^{
                         [self.backImageView removeFromSuperview];
                         [self addSubview:self.frontImageView];}

                     completion:^(BOOL finished){
                         //nothing
                     }];

但我没有得到翻转动画。正面图像视图立即出现。我做错了什么?

【问题讨论】:

    标签: ios uiview uiviewanimation


    【解决方案1】:

    你在使用

    时犯了一个愚蠢的错误
    animateWithDuration:delay:options:animations:completion:
    

    而不是

    transitionFromView:toView:duration:options:completion:
    

    你的代码应该是:

    [UIView transitionFromView:backImageView
                        toView:frontImageView
                      duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    completion:^(BOOL finished) {
                        // animation completed
                    }];
    

    【讨论】:

      猜你喜欢
      • 2010-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多