2014-01-22 57 views
1

我试图使用UIViewAnimationOptionTransitionFlipFromTop来实现下面的动画,它不起作用并立即改变图像。以下是我使用的代码:UIButton没有UIViewAnimationOptionTransitionFlipFromTop的动画

[self.thanksButton setImage:[UIImage imageNamed:@"frame1_image"] forState:UIControlStateNormal]; 

[UIView animateWithDuration:3.0 delay:0 options:UIViewAnimationOptionTransitionFlipFromTop animations:^{ 
} completion:^(BOOL finished) { 
    [self.thanksButton setImage:[UIImage imageNamed:@"frame4_image"] forState:UIControlStateNormal]; 
}]; 

还试图通过一个使用嵌套动画这样的图像分成四个不同的框架和应用这些图像之一,

[UIView animateWithDuration:3.0 animations:^{ 
    [self.thanksButton setImage:[UIImage imageNamed:@"frame2_image"] forState:UIControlStateNormal]; 
} completion:^(BOOL finished) { 
    [UIView animateWithDuration:3.0 animations:^{ 
     [self.thanksButton setImage:[UIImage imageNamed:@"frame3_image"] forState:UIControlStateNormal]; 
    } completion:^(BOOL finished) { 
     [UIView animateWithDuration:3.0 animations:^{ 
      [self.thanksButton setImage:[UIImage imageNamed:@"frame4_image"] forState:UIControlStateNormal]; 
     } completion:^(BOOL finished) { 

     }]; 
    }]; 
}]; 

请让我知道需要什么在这里固定。以下是动画:

enter image description here

回答

1

的setImage不能动画,只是通过它把UIView的animationblock,因此completionBlock不不等待3秒,但立刻调用。要看到一个实际的效果设置self.thanksbutton像0.3,0.5,1(我不认为它会看起来不错,但你应该看到的效果)一些阿尔法。

另外,我会做2个按钮,所以我可以使用:

[UIView transitionFromView:firstButton 
         toView:theOtherButton duration:0.3f 
         options:UIViewAnimationOptionTransitionFlipFromBottom 
        completion:^(BOOL finished) { 
        }]; 
+0

谢谢,虽然必须有一个本地方法。但是这对我来说是个诡计!谢谢! –