iOS Learning-22 Global Marquee

Source: Internet
Author: User

Ideas:

1. Create a singleton

+ (instancetype) sharemanager {    static ccpaomaview *pmodel = nil;     Static dispatch_once_t once;    Dispatch_once (&once, ^{        = [[Ccpaomaview alloc]initwithframe:cgrectmake (0  00.0468 *kscreenheight)];    });     return Pmodel;}

2. The received data in the local plist, does not apply to a large amount of data, each time the first data read, read to complete the deletion of the entire plist, and then the rest of the re-deposited into the plist

3. According to the animation agent, listen to the end of the animation execution, set the animation instance to nil

- (void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) flag{NSLog (@"%@", [Self.paomaLabel.layer Animationforkey:@"Paomadeng"]); if([Self.paomaLabel.layer Animationforkey:@"Paomadeng"] ==anim) {        //removing the first set of data[_array Removeobjectatindex:0]; //Remove entire plist[Ccpaomamodel removepaomaplist]; //re-write[_array writetofile:[ccpaomamodel filename] atomically:yes]; //after the animation stops, set the instance to nil_pmaniamtion =Nil; //Remove the marquee after the array is empty        if(_array.count >0) {[Self showPaomaView:self.superview]; }Else{Self.hidden=YES;        [Self removefromsuperview]; } NSLog (@"%@", Self.array); }}

4. Determine if the animation instance is empty, so that the switch interface, the marquee continues, not to start again

- (void) Paomaaniamtion: (cgfloat) count{//to determine that an animation instance is not present, exists, or does not exist.    if(_pmaniamtion = =Nil) {_pmaniamtion=[cabasicanimation animation]; _pmaniamtion.keypath=@"transform.translation.x"; CGFloat W=cgrectgetwidth (_paomalabel.bounds); _pmaniamtion.fromvalue=@ (W); _pmaniamtion.tovalue= @(-v); _pmaniamtion.duration=_anitime; _pmaniamtion.repeatcount=count; _pmaniamtion.removedoncompletion= NO;//animation end does not remove_pmaniamtion.fillmode = Kcafillmodeforwards;//the end of the animation will remain the end of the state_pmaniamtion.Delegate= self;//Set up proxy[_paomalabel.layer addanimation:_pmaniamtion Forkey:@"Paomadeng"]; }Else{_pmaniamtion.repeatcount=count; }}

5. Toggle the interface, pause, resume animation

#pragma mark-interface appears, disappears, creates, resumes, pauses animation-(void) viewwillappear: (BOOL) animated {    [_paomaview ShowPaomaView:self.view];    [_paomaview resumeanimation];} -(void) viewwilldisappear: (BOOL) animated {    [_paomaview pauseaniamtion];}

Don't talk much, GitHub see code

iOS Learning-22 Global Marquee

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.