gpt4 book ai didi

objective-c - 每个 CALayer 是否都有自己的 CGContextRef?

转载 作者:行者123 更新时间:2023-12-03 17:32:53 25 4
gpt4 key购买 nike

我正在尝试找出在包含非矩形路径的 CALayer 上进行命中检测的最佳方法。我知道CGContextPathContainsPoint函数,但我不确定如何获取对适当的 CGContextRef 的引用当我需要进行点击检测时(例如鼠标按下)。保留对 CGContextRef 的引用是否安全?被传递到(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx用于命中检测目的的委托(delegate)方法?我不确定是否相同CGContextRef可能会被其他层修改。

最佳答案

让图层拥有一个 CGPath 并对其进行 HitTest 。这样您就不必担心保留上下文是否安全,也不必每次都重新绘制路径。

关于objective-c - 每个 CALayer 是否都有自己的 CGContextRef?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2654376/

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