У меня есть ярлык и текст внутри него. Я хочу, чтобы мой текст перемещался по ширине ярлыка, как цифровая информационная доска. Как это сделать в iOS? Я пытался с этим кодом (который я получил здесь: http://www.youtube.com/watch?v=EFoNEjPwTXM), но он не работает:Как сделать текст ярлыка, перемещаемый по экрану в iOS?
В файле .m:
-(void)time: (NSTimer *) theTimer
{
currentSong.center = CGPointMake(currentSong.center.x - 3.5, currentSong.center.y);
if (currentSong.center.x < - (currentSong.bounds.size.width/2))
{
currentSong.center = CGPointMake (320 + (currentSong.bounds.size.width/2), currentSong.center.y);
}
}
В viewDidLoad
:
timer = [NSTimer timerWithTimeInterval:0.09 target:self selector:@selector(time:) userInfo:nil repeats:YES];
В заголовочный файл:
IBOutlet UILabel *currentSong;
IBOutlet NSTimer *timer;
-(void)time: (NSTimer *) theTimer;
@end
Это называется "Marquee": http://stackoverflow.com/questions/11255988/continuous-scrolling-of-uilabel-like-marquee – trojanfoe