cbpowell / MarqueeLabel

A drop-in replacement for UILabel, which automatically adds a scrolling marquee effect when the label's text does not fit inside the specified frame
MIT License
4.21k stars 564 forks source link

How to detect string has finish. #213

Closed sajidhussain closed 6 years ago

sajidhussain commented 6 years ago

HI, Is there any way to detect string is finish in UIlabel to scroll. I am going to implement Marquee in my app but i have some different scenario to implement. I am getting information from web service it has string to play in Marquee. So please let me know how to show or detect scroll has finish or please suggest me how can i achieve this.

Please follow the general troubleshooting steps first:

Usage Details

Expected Behavior

Actual Behavior

Steps to Reproduce the Problem

1. 1. 1.

cbpowell commented 6 years ago

Hi @sajidhussain, the easiest way to detect when the scroll animation is finished is to override the labelReturnedToHome function in a custom subclass of MarqueeLabel. That will be called whenever the label animation returns to the "home" position where the animation starts, and you can use that to trigger your other events.

Hope this helps!

iDevelopper commented 6 years ago

It is not very ideal to subclass MarqueeLabel just for that, MarqueeLabel is already a UILabel subclass. The nice way would be a protocol...

cbpowell commented 6 years ago

Well that's the beauty of subclassing, it doesn't really matter how many layers down you are, and enables you to add features not in the basic set.

But I understand your point - I've never needed that functionality myself, so I haven't spent the time to implement and test it. I'd be happy to support a pull request though! It should be easy to add a delegate pattern.