Skip to content

Instantly share code, notes, and snippets.

@sujinnaljin
Created July 31, 2021 20:26
Show Gist options
  • Select an option

  • Save sujinnaljin/e22002681b30c27a31dfc2f348dc4a86 to your computer and use it in GitHub Desktop.

Select an option

Save sujinnaljin/e22002681b30c27a31dfc2f348dc4a86 to your computer and use it in GitHub Desktop.
func addSnowLayer() {
let cell = CAEmitterCell()
cell.contents = UIImage(named: "EmojiTwo")!.cgImage
cell.birthRate = 5
cell.lifetime = 10
cell.scale = 0.1
cell.yAcceleration = 100
cell.alphaSpeed = -0.2
let emitterLayer = CAEmitterLayer()
emitterLayer.emitterShape = .line
emitterLayer.emitterSize = CGSize(width: view.frame.width,
height: view.frame.height)
emitterLayer.emitterPosition = CGPoint(x: view.center.x,
y: .zero)
emitterLayer.emitterCells = [cell]
view.layer.addSublayer(emitterLayer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment