I tried to set the property as atomic but it doesn’t seems to work anyway. Here’s the code. It move a label displaying the song name being played. And sometime it start jittering as if the label was supposed to be at two places at the same time. Any clue ? Some lock property maybe…
- (void)animateSongLabel
{
if (!self.player.rate) {
[UIView animateWithDuration:.5 animations:^{
self.songLabel.left = 25.f;
}];
return;
}
[UIView animateWithDuration:.25 delay:0. options:UIViewAnimationOptionCurveLinear animations:^{
self.songLabel.left -= 15.f;
} completion:^(BOOL finished) {
if (self.songLabel.right < -10.f) {
self.songLabel.left = 320.f;
}
[self animateSongLabel];
}];
}
The rock-bottom simplest way to make text that just sits there and scrolls sideways is to display an animated UIImage or animated UIImageView – especially the former, because it animates forever, which is probably what you want. Generate the successive UIImage objects in code by drawing your text slightly offset each time, and hand them to
animatedImageWithImages:duration:. Now wherever you show that image, it will be animating.Here’s some sample code to get you started (tweak to get precisely the effect you have in mind):