With view Settings

self.backView.clipsToBounds = YES;
Copy the code

Set up timer

[NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @ the selector (labelRoll) the userInfo: nil repeats: YES];Copy the code

run

- (void) labelRoll { CGPoint labelCenter = self.label.center; // When the x coordinate of the control exceeds the width of the viewif(labelCenter. X < self. BackView. Frame. Origin. X - self. Label, frame, the size, width) {/ / control control move since the view on the right side of the self. The customLab. Center = CGPointMake(self.backView.frame.size.width+self.label.frame.size.width/2, labelCenter.y); }else{/ / control controls movement (fine) self. Label. CustomLab. Center = CGPointMake (labelCenter. X - 5, labelCenter. Y); }}Copy the code