Viewcontroller.m
#import "ViewController.h"@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; /*Initialize Layer*/ //Create LayerCaemitterlayer *emitterlayer =[Caemitterlayer layer]; //Show BorderEmitterlayer.borderwidth =1. F; //given sizeEmitterlayer.frame = CGRectMake ( -, -, -, -); //Launch PointEmitterlayer.emitterposition = Cgpointmake (0,0); //Launch ModeEmitterlayer.emittermode =Kcaemitterlayersurface; //Launch ShapeEmitterlayer.emittershape =Kcaemitterlayerline; //Add Layer[Self.view.layer Addsublayer:emitterlayer]; /*Initializing particles*/Caemittercell*emittercell =[Caemittercell Emittercell]; //particle yield (that is, how much the particles produce)Emittercell.birthrate =1. F; //particle life cycle (seconds)Emittercell.lifetime = -. F; //Velocity of particlesEmittercell.velocity = -; //set the range of particle speed changes (if not set, then the velocity of the particles is always ten)//the speed value after setting is (between 7~13)Emittercell.velocityrange =3. F; //set Acceleration direction (Y-axis acceleration)Emittercell.yacceleration =2. F; //Particle emission angleEmittercell.emissionrange =4. f *M_1_pi; //set up a picture of the particle displayEmittercell.contents = (__bridgeID_nullable) ([UIImage imagenamed:@" One"]. Cgimage); //set the color of a particleEmittercell.color =[Uicolor Blackcolor]. Cgcolor; /*make Emitterlayer and Emittercell related*/Emitterlayer.emittercells=@[emittercell];}@end
:
Using Caemitterlayer to produce particle effects