首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在旋转iPhone的同时修改CABasicAnimation

在旋转iPhone的同时修改CABasicAnimation
EN

Stack Overflow用户
提问于 2012-05-11 21:57:16
回答 2查看 1.2K关注 0票数 3

我有一个可以使用CABasicAnimation旋转的using图像。当我得到一个指南针更新时,我会通过时间偏移来更改/更新图像的起始点。

这很好用,但当我从指南针获得更新并删除旧动画时,它会跳回开始位置,然后再移动到新的开始位置。这会导致闪烁效果。有没有办法同时删除和添加动画,或者以某种方式防止这种情况发生?

到目前为止,我的代码如下。

代码语言:javascript
运行
复制
[self.waveImage.layer RemoveAllAnimations];

CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0];
animation.toValue = [NSNumber numberWithFloat:2.0 * M_PI];
animation.duration = 1.0;
animation.repeatCount = HUGE_VALF;    // Repeat forever           
animation.speed = 1.0/duration;
animation.timeOffset = startingPhase;
animation.fillMode = kCAFillModeForwards;

[self.waveImageView.layer addAnimation:animation forKey:@"transform.rotation.z"];
EN

Stack Overflow用户

发布于 2012-05-11 22:02:34

查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10552801

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档