IOS animation to achieve Yuhua and cherry special effects _ios

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.