How to add Stretchable UIImage in the CALayer.contents?

Viewed 5567

I have a CALayer and I want to add to it a stretchable image. If I just do:

        _layer.contents = (id)[[UIImage imageNamed:@"grayTrim.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 15.0, 0.0, 15.0)].CGImage;

it won't work since the layers' default contentGravity is kCAGravityResize.

I've read that this could be accomplished using the contentsCenter but I cannot seem to figure out how exactly would I use that to achieve the stretched image in my CALayer.

Any ideas are welcome!

Horatiu

1 Answers
Related