ios4 – iOS 4.2:使用块动画翻转图像

前端之家收集整理的这篇文章主要介绍了ios4 – iOS 4.2:使用块动画翻转图像前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个代码我的应用程序:
  1. [UIView beginAnimations:nil context:NULL];
  2. [UIView setAnimationDuration:1];
  3. [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:imgView cache:YES];
  4. imgView.image = img2;
  5. [UIView commitAnimations];

但是在iOS 4.0及更高版本中不鼓励使用此方法,我应该使用transitionWithView:duration:options:animations:completion:

我不能让它正常工作.有人可以帮我吗
谢谢!

解决方法

  1. [UIView transitionWithView:imgView // use the forView: argument
  2. duration:1 // use the setAnimationDuration: argument
  3. options:UIViewAnimationOptionTransitionFlipFromLeft
  4. // check UIViewAnimationOptions for what options you can use
  5. animations:^{ // put the animation block here
  6. imgView.image = img2;
  7. }
  8. completion:NULL]; // nothing to do after animation ends.

猜你在找的iOS相关文章