我在裏面有一個標籤和文字。我希望我的文本像數字信息板一樣跨越標籤的寬度。如何在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];
在.h文件:
IBOutlet UILabel *currentSong;
IBOutlet NSTimer *timer;
-(void)time: (NSTimer *) theTimer;
@end
這是被稱爲「跑馬燈」:http://stackoverflow.com/questions/11255988/continuous-scrolling-of-uilabel-like-marquee – trojanfoe 2013-03-14 13:04:17