ios - 跑马灯动画效果,点击之后滚动速度部分加快部分减慢
巴扎黑
巴扎黑 2017-04-18 09:04:18
[iOS讨论组]

我做了个跑马灯的label,还在label上加了手势,点击label跳转到另外一个页面。
现在问题是当我点击label进入另一个页面后,再返回来,跑马灯的滚动速度变快了,但是到了最后的文字的时候又变的很慢。 下一次滚动也是这样,开头的文字一个就冲出来,然后就变慢,到最后的文字就很慢。

    CABasicAnimation *moveAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
    moveAnimation.toValue = [NSNumber numberWithFloat:-(_contentLabel.vWidth + DEVICE_WIDTH )];
    moveAnimation.duration = 18;
    moveAnimation.repeatCount = HUGE_VALF;
    moveAnimation.autoreverses = NO;
    moveAnimation.removedOnCompletion = NO;
    moveAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
        [_contentLabel.layer addAnimation:moveAnimation forKey:nil];
巴扎黑
巴扎黑

全部回复(1)
阿神

应该是重复添加动画了 这样处理看看
[_contentLabel.layer removeAnimationForKey:@"run"];
...
[_contentLabel.layer addAnimation:moveAnimation forKey:@"run"];

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号