简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM