【发布时间】:2012-10-22 17:43:47
【问题描述】:
我正在尝试用CGContextSetLineDash 画一条虚线。
这是我的代码:
float dashPhase = 0.0;
float dashLengths[] = {30, 30};
CGContextSetLineDash(context, dashPhase, dashLengths, 20.0);
self.previousPoint2 = self.previousPoint1;
self.previousPoint1 = previous;
self.currentPoint = current;
self.mid1 = [self pointBetween:self.previousPoint1 andPoint:self.previousPoint2];
self.mid2 = [self pointBetween:self.currentPoint andPoint:self.previousPoint1];
UIBezierPath* newPath = [UIBezierPath bezierPath];
[newPath moveToPoint:self.mid1];
[newPath addLineToPoint:self.mid2];
[newPath setLineWidth:self.brushSize];
但是,如果我画得很慢,它们不会出现虚线(见下图顶部),但如果我画得很快,它们会出现(见下图底部)。
为什么会这样?
【问题讨论】:
-
我看不出这与 Xcode 有什么关系。
标签: iphone objective-c ios cgcontext