Fran Fox
Fran Fox

Reputation: 575

How to remove an CAEmitterLayer?

I'm playing with particle system in iOS using CAEmitterLayer (like in this example) but i can't remove the particles when i want.

I'm trying the following code but it doesn't work:

[self.emitterLayer setLifetime:0];
[self.emitterLayer removeFromSuperlayer];
[self.setEmitterLayer:nil];

Any suggestions? Thanks!

Upvotes: 4

Views: 1208

Answers (2)

ralphb
ralphb

Reputation: 53

I have played around with views a lot in the last months esp. with ios 5.0 to 6.0 and my experience is that you can't remove most these views with "removeFrom" but you can hide them and show then at will. Especially if your logic takes place within one view or without a root view.

You only have to implement something like this: to hide it: [YourView setHidden:YES]; or to show it: [YourView setHidden:NO];

Hope this helps,

R.

Upvotes: 0

iEinstein
iEinstein

Reputation: 2100

Please use this

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

}

and please find the link that is helpful for you here

Upvotes: 3

Related Questions