Use UILabel to implement text scrolling (running horse lamp) and uilabel text scrolling

Source: Internet
Author: User

Use UILabel to implement text scrolling (running horse lamp) and uilabel text scrolling

-(Void) viewDidLoad {[super viewDidLoad]; // data source self. messageArray = [NSArray arrayWithObjects: @ "1", @ "2", @ "3", nil]; self. msgCount = 0; // display from the first entry}
-(Void) viewDidAppear :( BOOL) animated {// The first playback entry and add Timer to set the switching interval [self msgChange]; [nst1_scheduledtimerwithtimeinterval: 5.0f target: self selector: @ selector (msgChange) userInfo: nil repeats: YES];}
-(Void) msgChange {if (self. msgCount <self. messageArray. count) {self. scrollLabel. text = [self. messageArray objectAtIndex: self. msgCount]; self. msgCount ++;} else {self. scrollLabel. text = @ "no message"; // here, you can change the deletion to cyclic playback.} [self. scrollLabel sizeToFit]; CGRect frame = self. scrollLabel. frame; frame. origin. x = [UIScreen mainScreen]. bounds. size. width; self. scrollLabel. frame = frame; [UIView beginAnimations: @ "scrollLabelTest" context: NULL]; [UIView setAnimationDuration: 5.0f]; [UIView setAnimationCurve: Custom]; [UIView setAnimationDelegate: self]; [UIView setAnimationRepeatAutoreverses: NO]; [UIView setAnimationRepeatCount: 0]; frame = self. scrollLabel. frame; frame. origin. x =-frame. size. width; self. scrollLabel. frame = frame; [UIView commitAnimations];}

 

Related Article

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.