gpt4 book ai didi

ios - CGContextFillEllipseInRect 绘制点超过 1000 卡住应用程序

转载 作者:行者123 更新时间:2023-11-29 12:09:40 25 4
gpt4 key购买 nike

我已经使用 CGContextFillEllipseInRect 创建了 1000 多个点,它将停止应用程序,当绘图完成时,应用程序可以顺利运行任何选项

最佳答案

尝试使用 CALayerdrawsAsynchronously 属性并将其设置为 YES 用于您在其中绘制的 View - 这会将绘图命令发送到后台线程,您的主队列应该完好无损,界面应该保持响应。

更新:问题本身不是很清楚你把这些点画在哪里,但我假设它发生在 -drawInRect: 中。在任何时候,当您的 View 加载时,您都需要像这样配置CALayer:

self.layer.drawsAsynchronously = YES;

如果您在其中绘制的 View 在 Interface Builder 中可见,您可以使用 Identity Inspector (Option+CMD+3) 从 IB 中指定 drawsAsynchronously。找到 User Defined Runtime Attributes 部分,在其中添加 layer.drawsAsynchronousl 键并选中 Boolean 类型。

关于ios - CGContextFillEllipseInRect 绘制点超过 1000 卡住应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33869794/

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