2 lantianyiming lantianyiming 于 2013.05.17 11:03 提问

如何设置UIImageView动画?

如何设置UIImageView有动画?用了下面的代码进行动画设置,但是对imageView没有用:

MyImage=[[UIImageView alloc] initWithFrame:CGRectMake(10, 57, 220,140)];
MyImage.image=[UIImage imageNamed:@"image.png"];
MyImage.userInteractionEnabled = YES;
[self.view addSubview:MyImage];

[UIView beginAnimations : nil context : nil];
[UIView setAnimationCurve : UIViewAnimationCurveLinear];
[UIView setAnimationDuration : 1.00];

UIView setAnimationTransition : UIViewAnimationTransitionFlipFromLeft forView : MyImage  cache : YES];
[UIView commitAnimations];

1个回答

KindAzrael
KindAzrael   2013.05.17 19:10

代码没问题的 animation之间你没有写code当然没动画

[UIView beginAnimations : nil context : nil];
  [UIView setAnimationCurve : UIViewAnimationCurveLinear];
  [UIView setAnimationDuration : 1.00];
  //调整MyImage的位置 会看到image移动的动画
  MyImage.center = self.view.center;
  [UIView setAnimationTransition : UIViewAnimationTransitionFlipFromLeft forView : MyImage  cache : YES];
  [UIView commitAnimations];
Csdn user default icon
上传中...
上传图片
插入图片