How to use MarqueeLabel in Swift?

后端 未结 7 1550
无人及你
无人及你 2021-01-05 19:17

I want to know if there\'s a way to enable horizontal scrolling of text i.e., marquee type text. I have used this library: https://github.com/cbpowell/MarqueeLabel-Swift and

相关标签:
7条回答
  • 2021-01-05 19:56

    I used this little piece of code for my label to scroll like marquee:

    @IBOutlet weak var firstLabel: UILabel! 
    override func viewDidLoad() {
        super.viewDidLoad()
    
        UIView.animateWithDuration(12.0, delay: 1, options: ([.CurveLinear, .Repeat]), animations: {() -> Void in
                self.firstLabel.center = CGPointMake(0 - self.firstLabel.bounds.size.width / 2, self.firstLabel.center.y)
                }, completion:  { _ in })
    }
    

    Yes, it worked.

    0 讨论(0)
提交回复
热议问题