3

コードで生成した を表示するのに苦労している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.
4

1 に答える 1

2

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.

于 2012-01-23T17:22:18.110 に答える