[英]CGContextFillEllipseInRect draw dots more than 1000 stuck the app
我已经使用CGContextFillEllipseInRect创建了1000多个点,它将停止应用程序,并且在绘制完成后,该应用程序可以流畅地运行此选项
尝试使用CALayer
的drawsAsynchronously
属性并将其设置为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.