欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

iOS Core Animation: CALayer bringSublayerToFront?

程序员文章站 2022-03-16 17:17:46
...

 

 

-(void) bringSublayerToFront:(CALayer*)layer
{[layer removeFromSuperlayer];[self insertSublayer:layer atIndex:[self.sublayers count]-1];}-(void) sendSublayerToBack:(CALayer*)layer
{[layer removeFromSuperlayer];[self insertSublayer:layer atIndex:0];}

Note: if you don't use ARC, you may wish to add [layer retain] at top and [layer release] at bottom of both functions to make sure layer is not accidentally destructed in a case it has retain count = 1.