你将如何实现LED滚动效果?

时间:2010-12-01 12:02:23

标签: iphone uiview uiscrollview scroll

1 个答案:

答案 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]];
}