我正在用下面的代码为一个UIImage视图添加动画
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.duration = 1;
animation.toValue = [NSNumber numberWithFloat:M_PI];
animation.fromValue = [NSNumber numberWithInt:0];
[square.layer addAnimation:animation forKey:@"rotation"];一切正常,但我的数组在动画结束时采用了它原来的位置。我查看了layer属性,发现:
[square.layer setTransform:CATransform3DRotate(HERE, -M_PI, 0, 0, 0)];我不知道写什么来代替“这里”。你能帮我个忙吗?非常感谢!
发布于 2010-07-21 08:44:28
CATransform3DRotate()将要应用旋转的变换作为其第一个参数。如果你想旋转图层的变换,你可以使用
[square.layer setTransform:CATransform3DRotate(square.layer.transform, -M_PI, 0, 0, 0)];也就是说,如果您遇到的问题是层在动画结束时突然返回到开始位置,则只需将动画的removedOnCompletion属性设置为NO,并将其fillMode属性设置为kCAFillModeForwards。
https://stackoverflow.com/questions/3295114
复制相似问题