如何实现LED滚动效果,如下例所示?
LED Sign - LED Ticker emulator for the iPhone and iPad http://img.skitch.com/20101201-rsfh4p1bajb1wp94k466pdpiuj.preview.jpg答案 0 :(得分:3)
有时它会在其他posts评论中发表评论:)
为您准备了一些代码,但您应该实现字体'8Pin Matrix'
以获得逼真的感觉。
UILabel *label;
- (void)viewDidLoad {
[super viewDidLoad];
label = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 300, 20)];
label.font = [UIFont fontWithName:@"Courier-Bold" size:16.0];
label.backgroundColor = [UIColor blackColor];
label.textColor = [UIColor greenColor];
label.lineBreakMode = UILineBreakModeCharacterWrap; // otherwise you would get "…"
label.text = @"This LED Text will be scrolled "; // some blanks to get space between
[self.view addSubview:label];
[NSTimer scheduledTimerWithTimeInterval:0.12f target:self
selector:@selector(scrollLabel)
userInfo:nil repeats:YES];
}
- (void)scrollLabel {
label.text = [NSString stringWithFormat:@"%@%@", [label.text substringFromIndex:1], [label.text substringToIndex:1]];
}