2013-02-22 37 views
0

在UIView子类我有这样的:UIViewAnimation翻转不工作

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

但我不明白的翻转动画。正面图像视图立即出现。我究竟做错了什么?

回答

2

您正在使用的

transitionFromView:toView:duration:options:completion: 

animateWithDuration:delay:options:animations:completion: 

而不是一个愚蠢的错误代码应为:

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