继承UILable 重载drawRect,修改如下,即可
// Drawing code
- (void)drawRect:(CGRect)rect{
[super drawRect:rect];
float w = self.frame.size.width;
// if (motionWidth >= w) {
// return;
// }
CGRect frame = self.frame;
frame.origin.x = 320;
self.frame = frame;
[UIView beginAnimations:@"textAnimation" context:NULL];
// [UIView setAnimationDuration:8.0f*(w<320?320:w) /320.0];
[UIView setAnimationDuration:8.0f * (w < 320 ? 320:w ) / 320.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatAutoreverses:NO];//是否能反转
[UIView setAnimationRepeatCount:LONG_MAX];//重复次数
frame = self.frame;
frame.origin.x = -w;
self.frame = frame;
[UIView commitAnimations];
}