美文网首页
iOS tip(1)

iOS tip(1)

作者: DevYu | 来源:发表于2016-01-06 17:29 被阅读42次

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抗锯齿抗锯齿,参考这篇文章.

相关文章

网友评论

      本文标题:iOS tip(1)

      本文链接:https://www.haomeiwen.com/subject/yjixkttx.html