Removing all CALayer's sublayers

Posted by radex on Stack Overflow See other posts from Stack Overflow or by radex
Published on 2010-01-14T21:07:41Z Indexed on 2010/05/01 2:07 UTC
Read the original article Hit count: 414

Filed under:
|
|

Hi.

I have trouble with deleting all layer's sublayers. I do this manually, but it's unwanted code clutter. I found many topics about this in google, but no answer.

I tried to do something like this:

for(CALayer *layer in rootLayer.sublayers)
{
    [layer removeFromSublayer];
}

but it didn't work.

Also, i tried to clone rootLayer.sublayers into separate NSArray, but result was the same.

Any ideas?

regards, radex

PS. sorry for my English.

Edit:

I thought it works now, but I was wrong. It works good with CALayers, but it doesn't work with CATextLayers. Any ideas?

© Stack Overflow or respective owner

Related posts about core-animation

Related posts about objective-c