gpt4 book ai didi

iphone - 检查触摸区域而不仅仅是矩形的更好方法

转载 作者:搜寻专家 更新时间:2023-10-30 20:13:21 24 4
gpt4 key购买 nike

只是想知道是否有另一种方法可以使用特定形状的多边形来检查触摸区域,而不仅仅是使用 CGRectMake。

下面是这个例子的相同代码:

CGPoint location = [[Director sharedDirector] convertCoordinate: [touch locationInView: [touch view]]];
CGRect mySurface = CGRectMake(x, y, temp.contentSize.width, temp.contentSize.height);

if(CGRectContainsPoint(mySurface, location)) {
// do something
return kEventHandled;
}

正在考虑在 if 语句中使用多个 CGRect 对象,但想知道是否有更好的方法来执行此操作,例如 html 中的图像映射用于 anchor 。

最佳答案

考虑 CGPath:

创建路径,有很多GPath函数可用。然后使用:

检查图形路径中是否包含一个点。

bool CGPathContainsPoint (
CGPathRef path,
const CGAffineTransform *m,
CGPoint point,
bool eoFill
);

关于iphone - 检查触摸区域而不仅仅是矩形的更好方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1439534/

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