Use Uilabel to achieve scrolling caption movement effects
The code in this link also implements this effect.
Https://github.com/cbpowell/MarqueeLabel
The final effect is as follows:
The principle is as follows:
1. Get text
2. Calculate Text width
3. Put this label in ScrollView
4. Set the width of the ScrollView contentsize to the width of the text
5. Making animations
*6. Edge fade effect use a PNG image with transparent pixels
////ROOTVIEWCONTROLLER.M////Copyright (c) 2014 y.x. All rights reserved.//#import "RootViewController.h"#import "YXKit.h"#import "FontPool.h"@interfaceRootviewcontroller ()@end@implementationRootviewcontroller- (void) viewdidload{[Super Viewdidload]; Self.view.backgroundColor=[Uicolor Blackcolor]; //Registering FontsRegister_font (Bundlefont (@"new Pedicle Small meatball body. TTF"),@"new Pedicle Small Meatball body"); //Get textNSString *string=@"like this song of sentiment faint, as if how far away, in lamenting the love of past lives, is so soft, in the prayers of the afterlife of lingering. "Lotus's mind", you like the crystal-like glass, soft and soft to touch my sentimental heartstrings. I, Lotus's mind, who knows? I, Lotus's reserved, who knows? "; //Initialize labelUILabel *label = [UILabelNew]; Label.text=string; Label.numberoflines=0; Label.textcolor=[Uicolor Cyancolor]; Label.font= [Uifont Fontwithname:custom_font (@"new Pedicle Small Meatball body",0) Size: -. f]; //Calculate DimensionsCgsize size = [Label Boundingrectwithsize:cgsizemake (0,0)]; Label.frame=(cgrect) {cgpointzero, size}; //Initialize ScrollViewUiscrollview *showview =[[Uiscrollview alloc] Initwithframe:cgrectmake (0, -, the, Size.Height)]; Showview.contentsize=size; Showview.showshorizontalscrollindicator=NO; [ShowView Addsubview:label]; [Self.view Addsubview:showview]; //masks that form edgesUiimageview *imageview =[[Uiimageview alloc] Initwithframe:cgrectmake (0, -, the, Size.Height)]; Imageview.image= [UIImage imagenamed:@"BG"]; [Self.view Addsubview:imageview]; //Animation[UIView animatekeyframeswithduration:TenDelay:7options:uiviewkeyframeanimationoptionallowuserinteraction Animations:^{ //calculate the distance to moveCgpoint point =Showview.contentoffset; Point.x= Size.width- the. F; Showview.contentoffset=Point ; } Completion:^(BOOL finished) {}];}@end