While an UIView has a memory footprint of at least 4 * width * height pixels, I wonder how that would look when I create a CALayer only.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Having done some experimenting around this in the past, I found that the added overhead of the UIView object was very minimal.
回答2:
While an UIView has a memory footprint of at least 4 * width * height pixels
This statement is absolutely not true. The memory overhead of a UIView (compared to a CALayer) is just the size of the instance variables of the UIView class, plus a few instances of additional classes that will get allocated. The UIView instance variables take up about 24 bytes, and the additional data storage is probably the same, or less.
If UIView adds functionality that's useful for your application, then use it. The memory overhead is really of no concern.