Learn about IOS global Racing lights _ios

Source: Internet
Author: User

The example of this article for everyone to share the iOS global horse lamp production methods for your reference, the specific contents are as follows

Ideas:

1. Create a single case

+ (Instancetype) Sharemanager {
 static ccpaomaview *pmodel = nil;
 static dispatch_once_t once;
 Dispatch_once (&once, ^{
  pmodel = [[Ccpaomaview alloc]initwithframe:cgrectmake (0, 0, kscreenwidth, 0.0468 * Kscreenheight)];
 return pmodel;
}

2. There is a local plist of the received data, which does not apply to a large amount of data, reads the first data, reads the entire plist, and then saves the rest into the plist

3. According to the animation agent, listening to the animation execution end, the animation instance is placed as nil

-(void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) flag{
 NSLog (@ "%@", [Self.paomaLabel.layer animationforkey:@ "Paomadeng"]);
 if ([Self.paomaLabel.layer animationforkey:@ "Paomadeng"] = = Anim) {
  //Remove first set of data
  [_array removeobjectatindex:0] ;
  
  Removing the entire plist
  [Ccpaomamodel removepaomaplist];
  
  Re-written to
  [_array writetofile:[ccpaomamodel filename] atomically:yes];
  
  After the animation has stopped, place the instance as nil
  _pmaniamtion = nil;
  
  After the array is empty, remove the marquee
  if (_array.count > 0) {
   [self showPaomaView:self.superview];
  } else{
   Self.hidden = YES;
   [Self Removefromsuperview];
  }
  NSLog (@ "%@", Self.array);
 }

4. To determine whether the animation instance is empty, so that the switch interface, the race lights continue, rather than start again

-(void) Paomaaniamtion: (cgfloat) count{
 //Judgment animation instance does not exist, exists to continue, does not exist that creates
 if (_pmaniamtion = = nil) {
  _pmaniamtion = [cabasicanimation animation];
  _pmaniamtion.keypath = @ "transform.translation.x";
  CGFloat W = Cgrectgetwidth (_paomalabel.bounds);
  _pmaniamtion.fromvalue = @ (W);
  _pmaniamtion.tovalue = @ (w);
  _pmaniamtion.duration = _anitime;
  _pmaniamtion.repeatcount = count;
  _pmaniamtion.removedoncompletion = NO;  The animation end does not remove
  _pmaniamtion.fillmode = kcafillmodeforwards;//The State of the end of the animation remains
  _pmaniamtion.delegate = self;    Set Agent
  [_paomalabel.layer addanimation:_pmaniamtion forkey:@ "Paomadeng"];
 } else{
  _pmaniamtion.repeatcount = count;
 }
}

5. Toggle interface, pause, resume animation

#pragma mark-Interface appears, disappears, creates, restores, 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

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.