CAEmitterLayer
A layer that emits, animates, and renders a particle system.
Declaration
class CAEmitterLayerOverview
The particles, defined by instances of CAEmitterCell, are drawn above the layer’s background color and border.
The following code shows how to set up a simple point (the default emitterShape is point) particle emitter. It uses an image named RadialGradient.png as the cell contents and, by setting the emitter cell’s emissionRange to 2 × pi, the particles are emitted in all directions.
let emitterLayer = CAEmitterLayer()
emitterLayer.emitterPosition = CGPoint(x: 320, y: 320)
let cell = CAEmitterCell()
cell.birthRate = 100
cell.lifetime = 10
cell.velocity = 100
cell.scale = 0.1
cell.emissionRange = CGFloat.pi * 2.0
cell.contents = UIImage(named: "RadialGradient.png")!.cgImage
emitterLayer.emitterCells = [cell]
view.layer.addSublayer(emitterLayer)