MarqueeLabel没有工作,它只是在屏幕上显示为UILabel

时间:2014-02-10 07:11:52

标签: ios iphone

我已将https://github.com/cbpowell/MarqueeLabel链接中的文件包含在我的项目中

MarqueeLabel *continuousLabel2 = [[MarqueeLabel alloc] initWithFrame:CGRectMake(10, 440, self.view.frame.size.width-20, 20) rate:10 andFadeLength:10.0f]; 
continuousLabel2.tag = 101;
continuousLabel2.marqueeType = MLContinuous;
continuousLabel2.animationCurve = UIViewAnimationOptionCurveLinear;
continuousLabel2.continuousMarqueeExtraBuffer = 50.0f; 
continuousLabel2.numberOfLines = 1; 
continuousLabel2.opaque = YES; 
continuousLabel2.enabled = YES; 
continuousLabel2.textAlignment = NSTextAlignmentLeft; 
continuousLabel2.textColor = [UIColor colorWithRed:0.234 green:0.234 blue:0.234 alpha:1.000]; 
continuousLabel2.backgroundColor = [UIColor clearColor]; 
continuousLabel2.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.000]; 
continuousLabel2.text = @"This is another long label that scrolls continuously with a custom space between labels! You can also tap it to pause and unpause it!"
[self.view addSubview :continuousLabel2];

我已将上面的代码粘贴到我的项目中,但文本只显示为UILabel,而不是作为选框。请建议

3 个答案:

答案 0 :(得分:11)

将其放在代码末尾

 [continuousLabel2 restartLabel];

[self performSelector:@selector(startlabel) withObject:nil afterDelay:1.0];
-(void)startlabel{
        [continuousLabel2 restartLabel];
}

答案 1 :(得分:0)

我使用resetLabel来启动选框动画。

另外,不要忘记将labelize属性设置为NO。即

[self.marqueeLabel resetLabel];
self.marqueeLabel.labelize= NO;

答案 2 :(得分:0)

由Marith Label的Github文档提供 " MarqueeLabel会尽量在适当的时候自动开始滚动,但有时候你的视图/视图控制器在屏幕上的显示方式会让它绊倒。 使用restartLabel实例方法来"手动"开始在MarqueeLabel"

上滚动

[yourMarqueeLabel restartLabel];