CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.5;
animation.repeatCount = MAXFLOAT;
animation.autoreverses = YES;
animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DRotate(self.imageView.layer.transform, -kRotateValue, 0.0, 0.0, kRotateValue)];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DRotate(self.imageView.layer.transform, kRotateValue, 0.0, 0.0, kRotateValue)];
[self.imageView.layer addAnimation:animation forKey:@"wiggle"];
self.imageView.layer.allowsEdgeAntialiasing = true;
项目实现了一个这样的动画,但是发现切换tabbar或者进入后台再回来动画失效了,找了好久发现只需要设置 下边代码就好了.参考这里
animation.removedOnCompletion = NO;
其中
self.imageView.layer.allowsEdgeAntialiasing = true;
是CALayer抗锯齿抗锯齿,参考这篇文章.
网友评论