@interface XMWeatherView () @property(nonatomic,strong) CAEmitterLayer *sunshineEmitterLayer; @property(nonatomic,strong) CAEmitterLayer *rainDropEmitterLayer; @property(nonatomic,strong) UIImageView *backgroundView; @end
#pragma mark - 下雨特效
-(void)addRainningEffect{
self.backgroundView.image=[UIImage imageNamed:@"rainning.jpeg"];
//粒子发射器图层
self.rainDropEmitterLayer=[CAEmitterLayer layer];
//粒子发射器位置
_rainDropEmitterLayer.emitterPosition=CGPointMake(100, -30);
//粒子发射器的范围
_rainDropEmitterLayer.emitterSize=CGSizeMake(self.bounds.size.width*4, 0);
//发射模式
_rainDropEmitterLayer.emitterMode=kCAEmitterLayerOutline;
//粒子模式
_rainDropEmitterLayer.emitterShape=kCAEmitterLayerLine;
//创建粒子
CAEmitterCell *emitterCell=[CAEmitterCell emitterCell];
//设置粒子内容
emitterCell.contents=(__bridge id)([UIImage imageNamed:@"42-Raindrop"].CGImage);
//设置粒子缩放比例
emitterCell.scale=0.9;
//缩放范围
emitterCell.scaleRange=0.5;
//每秒粒子产生数量
emitterCell.birthRate=130;
//粒子生命周期
emitterCell.lifetime=5;
//粒子透明速度
emitterCell.alphaSpeed=-0.1;
//粒子速度
emitterCell.velocity=280;
emitterCell.velocityRange=100;
//设置发射角度
emitterCell.emissionLongitude=-M_PI;
// emitterCell.emissionRange=M_PI;
//设置粒子旋转角速度
// emitterCell.spin=M_PI_4;
//设置layer阴影
_rainDropEmitterLayer.shadowOpacity=1.0;
//设置圆角
_rainDropEmitterLayer.shadowRadius=2;
//设置偏移
_rainDropEmitterLayer.shadowOffset=CGSizeMake(1, 1);
//设置颜色
_rainDropEmitterLayer.shadowColor=[UIColor whiteColor].CGColor
;
//设置layer的粒子
_rainDropEmitterLayer.emitterCells=@[emitterCell];
_rainDropEmitterLayer.transform=CATransform3DMakeRotation(-M_PI/4, 0, 0, 1);
[self.layer addSublayer:_rainDropEmitterLayer];
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有