繁体   English   中英

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

[英]CGContextFillEllipseInRect draw dots more than 1000 stuck the app

我已经使用CGContextFillEllipseInRect创建了1000多个点,它将停止应用程序,并且在绘制完成后,该应用程序可以流畅地运行此选项

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

更新 :从问题本身来看,您不清楚在何处绘制这些点,但是我假设它发生在-drawInRect:. At any moment, when your view will load, you need to configure -drawInRect:. At any moment, when your view will load, you need to configure像这样-drawInRect:. At any moment, when your view will load, you need to configure CALayer`:

self.layer.drawsAsynchronously = YES;

如果在Interface Builder中可以看到绘制的视图,则可以使用Identity Inspector (Option + CMD + 3)从IB指定drawsAsynchronously 在“ 用户定义的运行时属性”的“查找”部分中,添加选中了布尔类型的layer.drawsAsynchronousl键。

暂无
暂无

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

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