
粒子效果.gif

粒子特效-百度百科.png
创建发射源
emitterLayer = [CAEmitterLayer layer];
设置粒子发送器 每秒钟发送的数量
emitterLayer.birthRate = self.emitterBirthRate?self.emitterBirthRate:1.0f;
发射源位置
emitterLayer.emitterPosition = emitterPosition;
发射源尺寸
emitterLayer.emitterSize = emitterSize;
发射形状的样式
emitterLayer.emitterShape = kCAEmitterLayerLine;
发射模式
emitterLayer.emitterMode = kCAEmitterLayerPoints;
创建粒子
CAEmitterCell *emitterCell = [CAEmitterCell emitterCell];
设置粒子内容
emitterCell.contents = (__bridge id _Nullable)(self.cellContents[i].CGImage);
粒子出生量
emitterCell.birthRate = self.cellBirthRate?self.cellBirthRate:10.0f;
生命周期
emitterCell.lifetime = self.cellLifetime?self.cellLifetime:120.0f;
生命周期范围
emitterCell.lifetimeRange = self.cellLifetimeRange?self.cellLifetimeRange:10.50f;
发射的速度
emitterCell.velocity = self.cellVelocity?self.cellVelocity:0.0f;
发射速度的范围
emitterCell.velocityRange = self.cellVelocityRange?self.cellVelocityRange:10.0f;
发射的纬度
emitterCell.emissionLatitude = self.cellEmissionLatitude?self.cellEmissionLatitude:0.0f;
发射的范围
emitterCell.emissionRange = self.cellEmissionRange?self.cellEmissionRange:M_PI/4;
加速度
emitterCell.yAcceleration = self.cellYAcceleration?self.cellYAcceleration:0.0f;
把粒子的cell 放到粒子发送器上
emitterLayer.emitterCells = cellArrM;
将粒子发射器添加到layer
[view.layer addSublayer:emitterLayer];

封装文件.png
网友评论