IOS scrolling label (LED, marquee, etc.) fast realization of source code

Source: Internet
Author: User

iOS scrolling label quickly implements the source code. Here the two labels used, move the frame implementation. Simple to use.





-(void) viewdidload {[Super viewdidload];    Additional setup after loading the view, typically from a nib.        NSString *str = @ "I Love you,ios-text scrolling label!";    Self.scrolllabel = [[UILabel alloc] Initwithframe:cgrectmake (0,100,self.view.frame.size.width, 44)];    Self.scrollLabel.text = str;        [Self.view AddSubview:self.scrollLabel]; Self.secondlabel = [[UILabel alloc] Initwithframe:cgrectmake (self.scrolllabel.frame.origin.x+ Self.scrollLabel.frame.size.width, SELF.SCROLLLABEL.FRAME.ORIGIN.Y, Self.scrollLabel.frame.size.width,    Self.scrollLabel.frame.size.height)];    Self.secondLabel.font = Self.scrollLabel.font;    Self.secondLabel.text = Self.scrollLabel.text;        [Self.view AddSubview:self.secondLabel]; [Self addanimation];//[[nstimer scheduledtimerwithtimeinterval:2 target:self selector: @selector (addanimation) Userinfo:nil Repeats:yes] fire];}    -(void) addanimation{cgrect scrollframe = self.scrollLabel.frame; CGRect Secondframe = Self.secondLabel.frame;  [UIView animatewithduration:4 delay:0 options:uiviewanimationoptioncurvelinear animations:^{self.scrollLabel.frame = CGRectMake (-self.scrolllabel.frame.size.width, SELF.SCROLLLABEL.FRAME.ORIGIN.Y,        Self.scrollLabel.frame.size.width, Self.scrollLabel.frame.size.height); Self.secondLabel.frame = CGRectMake (0, SELF.SECONDLABEL.FRAME.ORIGIN.Y, Self.secondLabel.frame.size.width,    Self.secondLabel.frame.size.height);        } completion:^ (BOOL finished) {self.scrollLabel.frame = Scrollframe;        Self.secondLabel.frame = Secondframe;    [Self addanimation]; }];}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IOS scrolling label (LED, marquee, etc.) fast realization of source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.