IOS Autoscroll标签从右向左滚动

时间:2014-07-23 09:12:55

标签: ios marquee

我正在使用AutoScrollLabelautoScrollLabel作为选框,当我需要label从左向右滚动时,它正常工作。

但是当我必须使用从右到左的方向时,我遇到了这个问题:

标签从最后一个单词开始到第一个单词?

为什么?

您可以在下面找到我的代码:

self.autoScrollLabel.textColor = [UIColor whiteColor];
self.autoScrollLabel.labelSpacing = 1; // distance between start and end labels
self.autoScrollLabel.pauseInterval = 0; 
self.autoScrollLabel.scrollSpeed = 70; // pixels per second
self.autoScrollLabel.textAlignment = NSTextAlignmentCenter; 
self.autoScrollLabel.fadeLength = 0; 
self.autoScrollLabel.scrollDirection = CBAutoScrollDirectionRight;
self.autoScrollLabel.text = [NSString stringWithFormat:@"%@%@",@"",@"hello hello1 hello1 heeloo3 hello3 hebe hehehe hgdghdhg he e e hehee hehee hehehehehehhe"];

2 个答案:

答案 0 :(得分:0)

我从未使用AutoScrollLabel课程,但我认为为了正常工作,您应该更改属性

self.autoScrollLabel.scrollDirection = CBAutoScrollDirectionLeft

滚动到左侧

答案 1 :(得分:0)

对于Swift,您可以调用此方法:

 func startMarqueeLabelAnimation() {

    DispatchQueue.main.async(execute: {

        UIView.animate(withDuration: 20.0, delay: 1, options: ([.curveLinear, .repeat]), animations: {() -> Void in
            self.marqueeLabel.center = CGPoint(x: 0 - self.marqueeLabel.bounds.size.width / 2, y: self.marqueeLabel.center.y)

        }, completion:  nil)

    })
}