iphone sdk中的CA基本动画

Abd*_*han 0 iphone cabasicanimation

我需要与CA BASIC ANIMATION同时旋转和移动相同的图像,在iphone sdk中是否有任何出路

任何帮助将受到高度赞赏


这是我的代码

 imgview = (UIImageView *)[self.view viewWithTag:imagenumber];
 CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
 anim.fromValue  = [NSValue valueWithCGPoint:CGPointMake(160 + x_movefrom, 240 + y_movefrom)];
 anim.toValue    = [NSValue valueWithCGPoint:CGPointMake(160 + x_moveto, 240 + y_moveto)];
 anim.duration   = 2;
 anim.removedOnCompletion = YES;

 //imgview = (UIImageView *)[self.view viewWithTag:imagenumber];

CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnim.toValue = [NSNumber numberWithFloat:0.0];
opacityAnim.removedOnCompletion = NO;

CAAnimationGroup *animGroup = [CAAnimationGroup animation];
animGroup.animations = [NSArray arrayWithObjects:opacityAnim,anim, nil];
animGroup.duration = 2;
animGroup.delegate = self;
animGroup.removedOnCompletion = NO;
[imgview.layer addAnimation:animGroup forKey:nil];
Run Code Online (Sandbox Code Playgroud)

ser*_*gio 5

你可以在这里找到一个示例代码来做到这一点.

关键是创建两个CABasicAnimation,然后将它们分组CAAnimationGroup.

关注你的代码:

要设置不透明度的动画,请尝试使用此:

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
Run Code Online (Sandbox Code Playgroud)

代替

CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
Run Code Online (Sandbox Code Playgroud)