在CAAnimationGroup中设置位置和旋转的动画使得位置最终不会更新

时间:2014-06-13 13:08:36

标签: ios rotation position caanimation

我试图使用显式动画为position的{​​{1}}和rotation属性设置动画,结果是UIView已成功更新但rotation已成功更新虽然我在将动画添加到视图图层后立即将图层的positionposition属性更新为其最终值,但视图的1}}确实更新了更新猜它是所谓的显式覆盖隐式动画技术?)。

这是我的代码:

rotation

如果我单独实现位置或旋转动画,代码表现良好,我得到了预期的结果。但当它与CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:@"position.y"]; move.fromValue = @(self.square.center.y); move.toValue = @(300); CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotate.fromValue = @(DEGREES_TO_RADIANS(0)); rotate.toValue = @(DEGREES_TO_RADIANS(45)); CAAnimationGroup *group = [CAAnimationGroup animation]; group.duration = 1.0; group.animations = @[move, rotate]; self.square.center = CGPointMake(self.square.center.x, 300); self.square.transform = CGAffineTransformMakeRotation(M_PI/4); [self.square.layer addAnimation:group forKey:nil]; 结合时,位置最终不会更新为最终值 这里有什么想法吗?

1 个答案:

答案 0 :(得分:0)

也许试试这个:当然还有你的价值观:

[UIView animateWithDuration:1.0f animations:^{
   self.square.center = CGPointMake(10, 10);
   self.square.transform =CGAffineTransformMakeRotation(90);
 }completion:nil];