IOS Marquee Text

by / Monday, 30 September 2013 / Published in Ipad, Iphone

MarqueeLabel is a UILabel subclass adds a scrolling marquee effect when the text of the label outgrows the available width. The label scrolling direction and speed/rate can be specified as well. All standard UILabel properties (where it makes sense) are available in MarqueeLabel and it behaves just like a UILabel.

Here we will show how to animate label text throughout the UILabel in our project.To do so,first of all we need to add QuartzCore framework to our project from Linked Frameworks section.Now in UIStoryboard we need to take a UILabel and a UIButton.We will animate the UILabel text on clicking the Button.

Now in .h file of our controller we need to add following:

@interface ViewController : UIViewController{

UIView *messageView;

CGSize messageSize;


We also need to take a string variable to maintain the start stop activity of label text animation.Now in .m file of our controller we need to add following method:

- (void)animateLabeltext:(UILabel *)newView{

NSString * lbltest=newView.text;,;

[UIView animateWithDuration:lbltest.length/8


options:UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction

animations:^(void) {,;


completion:^(BOOL finished) {

if(finished) {

[self animateLabeltext:newView];





Now in button on click we need to do the following manipulation:

if([self.animationstatus isEqualToString:@"no"]){


[self.animatebutton setTitle:@"Stop Animating" forState:UIControlStateNormal];

[self animateLabeltext:ReqLbl];




self.ReqLbl.frame=CGRectMake(8.0, 20.0, 303.0, 80.0);

[self.animatebutton setTitle:@"Start Animating" forState:UIControlStateNormal];

[self.ReqLbl.layer removeAllAnimations];