Home>

First look at the effect map:

Directly below the code:

For particle effects, I only serve Apple systems,caemitter Particle special effects provide very rich attributes to achieve various effects (raindrops, snowflakes, meteors), the usage is simple and high. First createcaemitterlayer particle emitter layer,caemittercell particle unit,Then setas needed somany The properties of the particle unit are ok. Finally, pay attention to theof the particle emitter layer. 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,Use your imagination at the end,How to love how to play!

#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);
  //range of the particle emitter
  _raindropemitterlayer.emittersize=cgsizemake (self.bounds.size.width * 4, 0);
  //transmission mode
  _raindropemitterlayer.emittermode=kcaemitterlayeroutline;
  //Particle mode
  _raindropemitterlayer.emittershape=kcaemitterlayerline;
  //Create particles
  caemittercell * emittercell=[caemittercell emittercell];
  //Set particle content
  emittercell.contents=(__ bridge id) ([uiimage imagenamed:@"42-raindrop"]. cgimage);
  //Set particle scaling
  emittercell.scale=0.9;
  //Zoom range
  emittercell.scalerange=0.5;
  //Number of particles generated per second
  emittercell.birthrate=130;
  //particle life cycle
  emittercell.lifetime=5;
  //Particle transparency speed
  emittercell.alphaspeed=-0.1;
  //Particle speed
  emittercell.velocity=280;
  emittercell.velocityrange=100;
  //Set the launch angle
  emittercell.emissionlongitude=-m_pi;
//emittercell.emissionrange=m_pi;
  //Set particle rotation angular velocity
//emittercell.spin=m_pi_4;
  //Set layer shadow
  _raindropemitterlayer.shadowopacity=1.0;
  //Set rounded corners
  _raindropemitterlayer.shadowradius=2;
  //Set offset
  _raindropemitterlayer.shadowoffset=cgsizemake (1, 1);
  //Set the color
  _raindropemitterlayer.shadowcolor=[uicolor whitecolor] .cgcolor
  ;
  //Set the particles of the layer
  _raindropemitterlayer.emittercells [email protected][emittercell];
  _raindropemitterlayer.transform=catransform3dmakerotation (-m_pi/4, 0, 0, 1);
  [self.layer addsublayer:_raindropemitterlayer];
}

Sakura ’s code is similar.Please make up yourself.

ios
  • Previous AngularJS basic ng-keypress directive simple example
  • Next AngularJS basic ng-model instruction detailed and sample code