调试 UIBezierPath

发布于 2024-12-28 15:38:33 字数 676 浏览 0 评论 0原文

我正在努力显示我在代码中生成的 UIBezierPath ,因此在尝试调试它时,我想打印它所绘制的坐标。我在任何地方都找不到这种技术。鉴于下面的代码,有人可以分享这个吗?

谢谢

UIBezierPath* beizerPath2 = [UIBezierPath bezierPath];
[beizerPath2 moveToPoint:CGPointMake(0.0, 167)];    
[beizerPath2 addLineToPoint:CGPointMake(100, 40)]; 
[beizerPath2 addLineToPoint:CGPointMake(200, 70)];    
[beizerPath2 addLineToPoint:CGPointMake(300, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 167)];    
[beizerPath2 closePath];

CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = [beizerPath2 CGPath];

//print Bezier/Path co-ordinates here.

I'm struggling to display a UIBezierPath that I generate in code, so in my attempt to debug it, I want to print the coordinates it is plotted on. I can't find this technique anywhere. Can someone share this, given the code below?

Thanks

UIBezierPath* beizerPath2 = [UIBezierPath bezierPath];
[beizerPath2 moveToPoint:CGPointMake(0.0, 167)];    
[beizerPath2 addLineToPoint:CGPointMake(100, 40)]; 
[beizerPath2 addLineToPoint:CGPointMake(200, 70)];    
[beizerPath2 addLineToPoint:CGPointMake(300, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 30)];    
[beizerPath2 addLineToPoint:CGPointMake(320, 167)];    
[beizerPath2 closePath];

CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = [beizerPath2 CGPath];

//print Bezier/Path co-ordinates here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日情怀 2025-01-04 15:38:33

不确定“绘制的坐标”是什么意思。您可以使用 -bounds 方法获取路径的最小外接矩形。

当您正在调试并想要使用 NSLog() 时,也不要忽视非常有用的 NSString 宏,例如 NSStringFromCGRect(),例如,

NSLog(@"%@", NSStringFromCGRect([path bounds]));

如果我误解了您的问题,请澄清。

Not sure what you mean by "co-ordinates it is plotted on." You can get the minimum bounding rectangle for a path with the -bounds method.

When you are debugging and want to use NSLog(), also don't overlook the very helpful NSString macros, such as NSStringFromCGRect(), e.g.

NSLog(@"%@", NSStringFromCGRect([path bounds]));

If I misunderstood your question, please clarify.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文