Creating particles with CAEmitterLayer

suggest change

The CAEmitterLayer class provides a particle emitter system for Core Animation. The particles are defined by instances of CAEmitterCell.

The particles are drawn above the layer’s background color and border.

frame, cells, and layer must already exist. cells is an array of CAEmitterCell. kCAEmitterLayerLine is the Core Animation constant for a line-shaped emitter.

var emitter = CAEmitterLayer()

emitter.emitterPosition = CGPoint(x: frame.size.width / 2.0, y: -20)
emitter.emitterShape = kCAEmitterLayerLine
emitter.emitterSize = CGSize(width: frame.size.width, height: 1)

emitter.emitterCells = cells
layer.addSublayer(emitter)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents