Let's take a look at the effect chart:
The following direct code:
Particle effects I only take the apple system, CAEmitter
particle effects provide a very rich property to achieve a variety of effects (raindrops, snowflakes, meteors), the use of simple B-height. Start by creating a CAEmitterLayer
particle emitter layer, a CAEmitterCell
particle element, and then set somany
the properties of the particle unit as needed to OK, and finally note that the particle emitter layer is layer
added to the entire background sublayer
.
@interface Xmweatherview ()
@property (nonatomic,strong) Caemitterlayer *sunshineemitterlayer;
@property (Nonatomic,strong) Caemitterlayer *raindropemitterlayer;
@property (Nonatomic,strong) Uiimageview *backgroundview;
@end
Each attribute has a detailed comment, and finally play your imagination, love how to play it!
#pragma mark-Rain effect-(void) addrainningeffect{self.backgroundview.image=[uiimage imagenamed:@ "Rainning.jpeg"];
Particle emitter layer self.raindropemitterlayer=[caemitterlayer layer];
Particle emitter position _raindropemitterlayer.emitterposition=cgpointmake (100,-30);
The range of the particle emitter _raindropemitterlayer.emittersize=cgsizemake (self.bounds.size.width*4, 0);
Launch mode _raindropemitterlayer.emittermode=kcaemitterlayeroutline;
Particle mode _raindropemitterlayer.emittershape=kcaemitterlayerline;
Create particle Caemittercell *emittercell=[caemittercell Emittercell]; Sets the particle content emittercell.contents= (__bridge id) ([uiimage imagenamed:@ "42-raindrop"].
Cgimage);
Set the particle scaling ratio emittercell.scale=0.9;
Zoom range emittercell.scalerange=0.5;
The number of particles produced per second emittercell.birthrate=130;
Particle life cycle emittercell.lifetime=5;
particle transparency Velocity emittercell.alphaspeed=-0.1;
Particle velocity emittercell.velocity=280;
emittercell.velocityrange=100;
Setting the firing angle emittercell.emissionlongitude=-m_pi; Emittercell.emissionranGE=M_PI;
Set the particle rotational angular velocity//emittercell.spin=m_pi_4;
setting layer shadow _raindropemitterlayer.shadowopacity=1.0;
Set rounded corner _raindropemitterlayer.shadowradius=2;
Set offset _raindropemitterlayer.shadowoffset=cgsizemake (1, 1); Sets the color _raindropemitterlayer.shadowcolor=[uicolor Whitecolor].
Cgcolor;
Setting the layer particle _raindropemitterlayer.emittercells=@[emittercell];
_raindropemitterlayer.transform=catransform3dmakerotation (-M_PI/4, 0, 0, 1);
[Self.layer Addsublayer:_raindropemitterlayer]; }
Cherry blossom code similar to the same, please own brain repair.
This article is here, we have any comments and questions to remember timely feedback oh, I hope this article for everyone to develop iOS help.