HelloMoon
HelloMoon

Reputation:

How to add a naked CALayer as "subview" to a UIView?

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?

Upvotes: 3

Views: 6234

Answers (1)

Mike Chen
Mike Chen

Reputation: 1123

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];

Upvotes: 14

Related Questions