Particle transmitter: caemitterlayer particle: Caemittercell gradient layer: Cagradientlayer
Add code:
@interfaceRootviewcontroller () @property (nonatomic, strong) Caemitterlayer*Emitterlayer;@end@implementationRootviewcontroller-(Caemitterlayer *) emitterlayer{if(_emitterlayer) {return_emitterlayer; } _emitterlayer=[[Caemitterlayer alloc]init]; [Self.view.layer Addsublayer:_emitterlayer]; return_emitterlayer;}- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.Self.view.backgroundColor =[Uicolor Whitecolor]; Self.title=@"Big head son"; Uiimageview*view =[[Uiimageview alloc]initwithframe:self.view.frame]; //view.center = Cgpointmake (200,450);View.contentmode =Uiviewcontentmodescaleaspectfit; View.image= [UIImage imagenamed:@"1.jpg"]; [Self.view Addsubview:view]; Self.emitterLayer.frame= CGRectMake (0,0, Self.view.frame.size.width, -);//Self.view.backgroundColor = [Uicolor blackcolor]; //set the number of particle senders sent per secondSelf.emitterLayer.birthRate =1; //Self.emitterLayer.emitterPosition Center PointSelf.emitterLayer.position = Cgpointmake ( -, the); Self.emitterLayer.emitterShape=kcaemitterlayercircle; //set the style of the particle senderSelf.emitterLayer.renderMode =Kcaemitterlayeroldestlast; Self.emitterLayer.emitterMode=Kcaemitterlayervolume; Nsmutablearray*array =[[Nsmutablearray alloc]init]; for(intI=0; i<5; i++) {Caemittercell*cell3 =[Caemittercell Emittercell]; Cell3.contents= (ID) [UIImage imagenamed:[nsstring stringWithFormat:@"Peach Heart%d", i+1]]. Cgimage; //Particle Birth RateCell3.birthrate =1; //survival time, unit secondsCell3.lifetime =5; Cell3.lifetimerange=2; //Send SpeedCell3.velocity = -; Cell3.velocityrange= -; //direction of particle sendingCell3.emissionlatitude = -* (i+1) *m_pi/ the; //the acceleration sentCell3.yacceleration =- -; //range of emitted particles-radiansCell3.emissionrange = $; //Put the cell on the particle transmitter .[Array addobject:cell3]; } self.emitterLayer.emitterCells=Array; //Create a Gradient layer objectCagradientlayer *layer =[Cagradientlayer layer]; Layer.frame=Self.view.frame; //transparency of LayersLayer.opacity =0.2; //set the start point of a layer color gradientLayer.startpoint = Cgpointmake (0,0); //set the end point of a layer color gradientLayer.endpoint = Cgpointmake (1,0.5); //percent Array of color gradientsLayer.locations = @[@0.2,@0.6]; //An array of gradient colors does not accept a Cgcolor type that is strongly converted to an ID typeLayer.colors = @[(ID) [Uicolor Redcolor]. Cgcolor, (ID) [Uicolor Whitecolor]. Cgcolor, (ID) [Uicolor Cyancolor]. Cgcolor,]; [Self.view.layer Addsublayer:layer];//}
:
UI Basics-Particle animation