Creating particles with CAEmitterLayer
suggest changeThe 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)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents