Iphone – How to add a naked CALayer as “subview” to a UIView

cocoa-touchiphoneuikit

I think that adding a CALayer as "subview", somehow, does save a lot of memory. A UIView always comes with 3 copies of it's content bitmap (presentation layer, render tree and another one, plus the view itself, so every pixel is saved 4 times). But how could that be done?

Best Answer

UIView is basically a wrapper for CALayer. So you can add a layer directly to the view's layer. This can be done by calling

[[theView layer] addSublayer:newLayer];