Search code examples
swiftmarquee

how Marquee text of label on swift?


I want to create a marquee label in Swift. I tried some codes but could not get it to work.

I also can do this with animation but I have problem with repeating it.

I tried this too

any help will be appreciated.


Solution

  • Using a label which can Marquee up its content is really simple. Just add MarqueeLabel pod in your project.

    Swift:

    pod 'MarqueeLabel/Swift'
    

    And then select the label you wish to perform Marquee on and add the Custom Class MarqueeLabel to it in the Identity Inspector.

    That's it.

    This is the Simplest way to add marquee in your Label. After adding Custom Class MarqueeLabel if you want some spacing in between the last character and the first character of the content of your label then:

    Step 1: Select the label.

    Step 2: Go to Attributes Inspector and then increase the fadeLength attribute value the much you want to have. Applying value 10 to it is fair enough.

    If you wish to customize more then Add custom class MarqueeLabel to the Label and then take the outlet of that Label in you Code and customize it the way you want to.

    The outlet of that Label in your code should look like this:

    @IBOutlet var YOURLABELNAME: MarqueeLabel!
    

    If not so then start over by first adding the custom class to the label and then taking its outlet in the code file.