Caemitterlayer *snowemitter = [Caemitterlayer layer]; Example launch positionSnowemitter.emitterposition = Cgpointmake (120,20); Size of emission sourceSnowemitter.emittersize = Cgsizemake (Self.view.bounds.size.width *20,20); Launch modeSnowemitter.emittermode = Kcaemitterlayersurface; The shape of the emitter sourceSnowemitter.emittershape = Kcaemitterlayerline; Create a snowflake-type particleCaemittercell *snowflake = [Caemittercell Emittercell]; The name of the particleSnowflake.name =@ "Snow"; Velocity multiplier factor for particle parametersSnowflake.birthrate =1.0;Snowflake.lifetime =120.0; Particle velocitySnowflake.velocity =10.0; Velocity range of particlesSnowflake.velocityrange =10; Acceleration components in the Y-direction of particlesSnowflake.yacceleration =2; Surrounding emission angleSnowflake.emissionrange =0.5 * M_PI; Sub-rotation angle rangeSnowflake.spinrange =0.25 * M_PI;Snowflake.contents = (ID) [[UIImage imagenamed:@ "Dazflake"] cgimage]; Set the color of a snowflake-shaped particleSnowflake.color = [[Uicolor colorwithred:0.200 Green:0.258 Blue:0.543 Alpha:1.000] cgcolor]; Create a star-shaped particleCaemittercell *snowflake1 = [Caemittercell Emittercell]; The name of the particleSnowflake1.name =@ "Snow"; Velocity multiplier factor for particle parametersSnowflake1.birthrate =1.0;Snowflake1.lifetime =120.0; Particle velocitySnowflake1.velocity =10.0; Velocity range of particlesSnowflake1.velocityrange =10; Acceleration components in the Y-direction of particlesSnowflake1.yacceleration =2; Surrounding emission angleSnowflake1.emissionrange =0.5 * M_PI; Sub-rotation angle rangeSnowflake1.spinrange =0.25 * M_PI; The color of the particle's content and contentSnowflake1.contents = (ID) [[UIImage imagenamed:@ "Dazstaroutline"] cgimage];Snowflake1.color = [[Uicolor colorwithred:0.600 Green:0.658 Blue:0.743 Alpha:1.000] cgcolor]; snowemitter.shadowopacity = 1.0; Snowemitter.shadowradius = 0.0; Snowemitter.shadowoffset = Cgsizemake (0.0, 1.0); //particle edge color snowemitter.shadowcolor = [[Uicolor redcolor] cgcolor]; snowemitter.emittercells = [Nsarray arraywithobjects:snowflake,snowflake1,nil]; [Self.view.layer insertsublayer:snowemitter Atindex:0]; additional setup after loading the view
iOS fireworks fire rain Snowflakes and other special effects properties