本文介绍了在iphone中自动滚动字幕标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个UILabel,我想像HTML中的marquee标签一样滚动,我该怎么做?
I have an UILabel that I want to scroll like marquee tag in HTML, how am I supposed to do that?
#define LEFTSCROLLDIRECTION 0
#define RIGHTSCROLLDIRECTION 1
MarqueeLabel *marquee = [[MarqueeLabel alloc] initWithFrame:CGRectMake(10, 10, 300, 30)];
label.scrollDirection = LEFTSCROLLDIRECTION;
[self.view addSubview:marquee];
编辑
我找到了类似乎首先起作用。 。
Edit
I have found this class for this that seems to work at first..
但是这里有一个错误..如果我在UINavigationController中向前导航并在一段时间之后弹出pushViewController,则autoScrollLabel会停止动画..
But there is a fault in this.. if I navigate forward in UINavigationController and pop that pushedViewController after a time, the autoScrollLabel stops animating..
AutoScrollLabel *autoScrollLabel = [[AutoScrollLabel alloc] init];
autoScrollLabel.text = @"Hi Mom! How are you? I really ought to write more often.";
autoScrollLabel.textColor = [UIColor yellowColor];
推荐答案
查看开源组件,实际上叫做MarqueeLabel。
Check out this open source component, actually called MarqueeLabel.
这让这很容易。
这篇关于在iphone中自动滚动字幕标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!