Most efficent way to create a CALayer with an image in it?

Michael Gaylord picture Michael Gaylord · Jun 14, 2009 · Viewed 9.1k times · Source

I am wondering what the most efficient way is to make a CALayer with an image in it.

I know you can load a UIImage and then call [image CGImage] but is this the best way of going about it? As far as I can tell from Apple's documentation this is the only way you can do it.

Answer

nielsbot picture nielsbot · May 10, 2011

Try this:

layer.contents = (__bridge id)[ uiimage CGImage ] ;

HTH