gpt4 book ai didi

ios - 通过使用另一个支持层减少 UILabel 的内存

转载 作者:行者123 更新时间:2023-11-28 21:40:59 25 4
gpt4 key购买 nike

我使用的是大尺寸标签,它占用了太多内存。 UILabel (CALayer) is using large amounts of virtual memory 中描述了该问题在How to suck down iOS memory without even trying .

是否可以通过例如交换 UILabel 的支持层? CATiledLayer?

我想做的是减少 UILabel 的使用内存。例如,使用清晰的背景颜色无济于事。不知道这是什么意思:

but then you don’t respond to the drawRect method to draw your view’s contents

最佳答案

您不能用 CATiledLayer 支持 UILabel,但也没有理由这样做。如果您要切换到 CATiledLayer(这可能是正确的解决方案),那么无论如何您都必须管理自己的布局。一旦您这样做了,UILabel 就不会给您带来太多好处。只需使用 UIView 并按照您的建议平铺它。

也就是说,您链接的问题讨论了创建 500 个 UILabels。这是一个疯狂的标签数量。您应该使用其他工具,例如 CATiledLayer、infinite UIScrollViewUITableView 等,它们允许您管理较少数量的可重用 View 。

关于ios - 通过使用另一个支持层减少 UILabel 的内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32074920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com