【发布时间】:2019-05-30 06:38:59
【问题描述】:
我会尽量保持简短。
拿下面的测试代码:
CGPath* path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, 318.43, 183.47);
CGPathAddCurveToPoint(path, nil, 322.98, 189.32, 327, 194.93, 329.81, 201.62);
CGPathAddLineToPoint(path, nil, 339.36, 182.58);
CGPathCloseSubpath(path);
CGPathMoveToPoint(path, nil, 327.8, 193.04);
CGPathAddCurveToPoint(path, nil, 323.06, 193.04, 323.06, 185.5, 327.8, 185.5);
CGPathAddCurveToPoint(path, nil, 332.54, 185.5, 332.54, 193.04, 327.8, 193.04);
CGPathCloseSubpath(path);
CGRect boundingBox = CGPathGetBoundingBox(path);
CGPoint testPoint = CGPointMake(200,185);
NSLog(@"path contains point=%d | bounding box contains point=%d",CGPathContainsPoint(path, nil, testPoint, NO), CGRectContainsPoint(boundingBox, testPoint) );
此代码在 iOS 10 上正确返回:
路径包含点=0 |边界框包含点=0
iOS 12 上的相同代码返回:
路径包含点=1 |边界框包含点=0
如您所见,在 iOS 12 上,CGPathContainsPoint 表示我的 testPoint 在形状内,即使形状的边界框表示不在。
在 CGPathContainsPoint 中将填充规则更改为 NO 不会改变任何内容。
有解决办法吗? 我之前尝试过苹果论坛,但似乎没有人在那里回答。
感谢您的帮助!
【问题讨论】:
-
似乎值得向我报告错误。 bugreport.apple.com
-
我报告了它......但我再次收到 3 个月前报告的另一个问题的回复。我看到错误报告的方式就像和一棵树谈论你的问题一样。 Stackoverflow 好多了。
标签: ios objective-c sdk core-graphics cgpath