3D-Touch改变CGContext的线宽 - 交叉线是错误的

时间:2016-06-30 05:44:00

标签: ios objective-c swift cgcontext 3dtouch

enter image description here

我想在绘图时用3D触摸更改线条的宽度。我正在使用库ACEDrawingView,它使用此代码绘制:

- (void)draw
{
   CGContextRef context = UIGraphicsGetCurrentContext();

   CGContextAddPath(context, path);
   CGContextSetLineCap(context, kCGLineCapRound);
   CGContextSetLineWidth(context, self.lineWidth);
   CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
   CGContextSetBlendMode(context, kCGBlendModeNormal);
   CGContextSetAlpha(context, self.lineAlpha);
   CGContextStrokePath(context);
}

我使用此代码根据touchesMoved:

中的压力更改lineWidth
// save all the touches in the path
UITouch *touch = [touches anyObject];

//3d touch
CGFloat maximumPossibleForce = touch.maximumPossibleForce;
CGFloat force = touch.force;
CGFloat normalizedForce = force/maximumPossibleForce;
CGFloat lineWidth = normalizedForce * 10;
self.currentTool.lineWidth = lineWidth;

这一切都很好,直到我绘制另一条与前一条线相交的线。然后它看起来像上面的图像。

任何帮助将不胜感激!如果需要,请询问更多代码,或快速查看ACEDrawingView。谢谢!

0 个答案:

没有答案
相关问题