Search code examples
iosswiftuilabelmarquee

how to implement marquee label in IOS using swift


How to implement MarqueeLabel in iOS. I found example in Objective-C but I'm using Swift.


Solution

  • For creating marquee in swift Add Below Class in your Project https://github.com/cbpowell/MarqueeLabel

    To do this first add the pod: pod 'MarqueeLabel'.

    And perform a pod update in your project.

    Then import pod in your working file: import MarqueeLabel

    Create one label and set the custom class as MarqueeLabel in the storyboard. Then:

    @IBOutlet weak var marqueeLabel:MarqueeLabel!
    

    In ViewDidLoad add this:

    marqueeLabel.type = .Continuous
    marqueeLabel.scrollDuration = 5.0
    marqueeLabel.animationCurve = .EaseInOut
    marqueeLabel.fadeLength = 10.0
    marqueeLabel.leadingBuffer = 30.0
    marqueeLabel.trailingBuffer = 20.0