2014-03-03 51 views
1

如标题所示,适用于我的NSBezierPathsetLineDash不会更改描边线。根本没有效果。NSBezierPath setLineDash不会产生任何效果

我期望它能让我的线条破灭。在图片上看到两条垂直的红线。

代码:

NSBezierPath* p= [NSBezierPath bezierPath]; 
CGFloat x = r.origin.x + r.size.width/2; 

float dash_pattern[]={15.,15.}; 
NSInteger count = sizeof(dash_pattern)/sizeof(dash_pattern[0]); 
[p setLineDash:(CGFloat*)dash_pattern count:count phase:0.]; // no effect ? 

[p moveToPoint:NSMakePoint(x, r.origin.y+r.size.height)]; 
[p lineToPoint:NSMakePoint(x, [view bounds].origin.y+[view bounds].size.height)]; 
[[NSColor redColor]set]; 

[p stroke]; 

enter image description here

回答

5

这是一个位在黑暗中拍摄,但在6​​4位OS X,CGFloatdouble而不是float。因此,您应该定义数组作为

CGFloat dash_pattern[]={15.,15.}; 

这也使得在setLineDash:(CGFloat*)dash_pattern不必要的显式转换。

+0

HOLY CRAP。工作。 – LiMar

+0

你已经救了我的一天,哥们! –

相关问题