简体   繁体   English

如何将裸体CALayer作为“子视图”添加到UIView?

[英]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. 我认为将CALayer添加为“子视图”,不知何故,确实可以节省大量内存。 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). UIView总是带有3个内容位图副本(表示层,渲染树和另一个,加上视图本身,因此每个像素保存4次)。 But how could that be done? 但是怎么办呢?

UIView is basically a wrapper for CALayer. UIView基本上是CALayer的包装器。 So you can add a layer directly to the view's layer. 因此,您可以直接将图层添加到视图的图层中。 This can be done by calling 这可以通过调用来完成

[[theView layer] addSublayer:newLayer];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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