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.