How do you remove a CAEmitterLayer when it ends the lifetime of it's CAEmitter Cells — instead of repeating until you remove it from super layer

痴心易碎 提交于 2019-12-05 19:05:42

The answer to this is, using CAEmitter, there is NO WAY -- delegate, etc -- to stop the emitter when it ends the cycle. The only thing you can do is gracefully remove it from the layer when you think it should be removed.

Ok, so I was able to sort of achieve this by creating an animation with delegate that fired along with the emitter. in the animationDidStop i made a for loop that went through my view hierarchy and looked for emitters and removed them. it's buggy and I still want a real solution, but this works for now.

for (CALayer *layer in _plusButton.layer.sublayers) {
    if (layer.class == [CAEmitterLayer class]) {
        [layer removeFromSuperlayer];
    }

}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!