How to use MarqueeLabel in Swift?

后端 未结 7 1553
无人及你
无人及你 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:44

    In SWIFT 3:

    @IBOutlet weak var YOURLABEL: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        UIView.animate(withDuration: 12.0, delay: 1, options: ([.curveLinear, .repeat]), animations: {() -> Void in
            self.YOURLABEL.center = CGPoint(x: 0 - self.YOURLABEL.bounds.size.width / 2, y: self.YOURLABEL.center.y)
        }, completion:  { _ in })
    }
    

提交回复
热议问题