欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS動(dòng)畫實(shí)現(xiàn)雨花與櫻花特效

 更新時(shí)間:2016年08月02日 09:48:16   投稿:daisy  
小編今天為大家?guī)硪粓鲣冷罏r瀝的夜空之雨和滿天飛舞的櫻花之戀,希望能在炎炎夏日為您帶來一絲清爽的涼意!學(xué)習(xí)iOS動(dòng)畫的小伙伴們可以參考學(xué)習(xí)。

先來看看效果圖:

下面直接上代碼:

粒子特效的話我只服蘋果系統(tǒng)的,CAEmitter粒子特效提供了非常豐富的屬性來實(shí)現(xiàn)各種效果(雨滴、雪花、流星),用法簡單B格高。首先創(chuàng)建好CAEmitterLayer粒子發(fā)射器圖層,CAEmitterCell粒子單元,然后根據(jù)需要設(shè)置somany粒子單元的屬性就OK了,最后注意要將粒子發(fā)射器圖層的layer添加到整個(gè)背景的sublayer上。

@interface XMWeatherView ()

@property(nonatomic,strong) CAEmitterLayer *sunshineEmitterLayer;

@property(nonatomic,strong) CAEmitterLayer *rainDropEmitterLayer;

@property(nonatomic,strong) UIImageView *backgroundView;

@end

每個(gè)屬性都有詳細(xì)注釋,最后就發(fā)揮您的想象力,愛怎么玩怎么玩吧!

#pragma mark - 下雨特效
-(void)addRainningEffect{

  self.backgroundView.image=[UIImage imageNamed:@"rainning.jpeg"];

  //粒子發(fā)射器圖層
  self.rainDropEmitterLayer=[CAEmitterLayer layer];

  //粒子發(fā)射器位置
  _rainDropEmitterLayer.emitterPosition=CGPointMake(100, -30);

  //粒子發(fā)射器的范圍
  _rainDropEmitterLayer.emitterSize=CGSizeMake(self.bounds.size.width*4, 0);

  //發(fā)射模式
  _rainDropEmitterLayer.emitterMode=kCAEmitterLayerOutline;

  //粒子模式
  _rainDropEmitterLayer.emitterShape=kCAEmitterLayerLine;

  //創(chuàng)建粒子
  CAEmitterCell *emitterCell=[CAEmitterCell emitterCell];

  //設(shè)置粒子內(nèi)容
  emitterCell.contents=(__bridge id)([UIImage imageNamed:@"42-Raindrop"].CGImage);

  //設(shè)置粒子縮放比例
  emitterCell.scale=0.9;

  //縮放范圍
  emitterCell.scaleRange=0.5;

  //每秒粒子產(chǎn)生數(shù)量
  emitterCell.birthRate=130;

  //粒子生命周期
  emitterCell.lifetime=5;

  //粒子透明速度
  emitterCell.alphaSpeed=-0.1;

  //粒子速度
  emitterCell.velocity=280;
  emitterCell.velocityRange=100;

  //設(shè)置發(fā)射角度
  emitterCell.emissionLongitude=-M_PI;
//  emitterCell.emissionRange=M_PI;

  //設(shè)置粒子旋轉(zhuǎn)角速度
//  emitterCell.spin=M_PI_4;

  //設(shè)置layer陰影
  _rainDropEmitterLayer.shadowOpacity=1.0;

  //設(shè)置圓角
  _rainDropEmitterLayer.shadowRadius=2;

  //設(shè)置偏移
  _rainDropEmitterLayer.shadowOffset=CGSizeMake(1, 1);

  //設(shè)置顏色
  _rainDropEmitterLayer.shadowColor=[UIColor whiteColor].CGColor
  ;

  //設(shè)置layer的粒子
  _rainDropEmitterLayer.emitterCells=@[emitterCell];

  _rainDropEmitterLayer.transform=CATransform3DMakeRotation(-M_PI/4, 0, 0, 1);

  [self.layer addSublayer:_rainDropEmitterLayer];
}

櫻花的代碼大同小異,請自行腦補(bǔ)。

這一篇就到這里了,大家有什么意見和問題記得及時(shí)反饋哦,希望本文對大家開發(fā)iOS有所幫助。

相關(guān)文章

最新評論