-(void)addImage{
//取消、停止所有的动画
[self.aUILabel.layer removeAllAnimations];
CGSize textSize = [self.aUILabel.text sizeWithFont:self.aUILabel.font];
CGRect lframe = self.aUILabel.frame;
lframe.size.width = textSize.width;
self.aUILabel.frame = lframe;
const float oriWidth = 180;
if (textSize.width > oriWidth) {
float offset = textSize.width - oriWidth;
[UIView animateWithDuration:3.0
delay:0
options:UIViewAnimationOptionRepeat //动画重复的主开关
|UIViewAnimationOptionAutoreverse //动画重复自动反向,需要和上面这个一起用
|UIViewAnimationOptionCurveLinear //动画的时间曲线,滚动字幕线性比较合理
animations:^{
self.aUILabel.transform = CGAffineTransformMakeTranslation(-offset, 0);
}
completion:^(BOOL finished) {
}
];
}
}
//取消、停止所有的动画
[self.aUILabel.layer removeAllAnimations];
CGSize textSize = [self.aUILabel.text sizeWithFont:self.aUILabel.font];
CGRect lframe = self.aUILabel.frame;
lframe.size.width = textSize.width;
self.aUILabel.frame = lframe;
const float oriWidth = 180;
if (textSize.width > oriWidth) {
float offset = textSize.width - oriWidth;
[UIView animateWithDuration:3.0
delay:0
options:UIViewAnimationOptionRepeat //动画重复的主开关
|UIViewAnimationOptionAutoreverse //动画重复自动反向,需要和上面这个一起用
|UIViewAnimationOptionCurveLinear //动画的时间曲线,滚动字幕线性比较合理
animations:^{
self.aUILabel.transform = CGAffineTransformMakeTranslation(-offset, 0);
}
completion:^(BOOL finished) {
}
];
}
}