gpt4 book ai didi

ios - 是否 drawRect : automatically check whether something is within the bounds of the CGRect passed to it?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:46:44 26 4
gpt4 key购买 nike

我想知道是否需要检查某些内容是否在传递给 drawRect: 的 CGRect 范围内,或者 drawRect: 是否会自动为我处理。

例如,假设我在屏幕上有 10 个 UIBezierPaths。每条曲线都在一个名为 curvesNSMutableArray 中。每次调用 drawRect: 时,它都会遍历此数组并绘制它在其中找到的曲线。如果使用移动一条曲线,我发现它包含CGRect调用[self setNeedsDisplayInRect:containingRect]。在我的 drawRect: 实现中,我是否需要亲自检查每个 UIBezierPaths 是否在传递给 drawRect:< 的 CGRect(使用 CGRectIntersectsRect),还是自动处理?

最佳答案

这属于一类优化,如果您认为在分析后有必要,则必须自己进行优化。

不幸的是,UIKit 并没有那么聪明。尽管它可能会太慢!

关于ios - 是否 drawRect : automatically check whether something is within the bounds of the CGRect passed to it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6800640/

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