Swift - UIGraphics 虚线关闭

Swift - UIGraphics dash line close

这是我的代码:

UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.view.frame.width,graphSize), false, 0)
    let context = UIGraphicsGetCurrentContext()
    CGContextSetStrokeColorWithColor(context, UIColor.whiteColor().CGColor)
    CGContextSetLineWidth(context, 0.3)
    CGContextBeginPath(context)
    CGContextMoveToPoint(context, width1, height1)
    CGContextAddLineToPoint(context, width11, height11)
    CGContextMoveToPoint(context, width2, height2)
    CGContextAddLineToPoint(context, width22, height22)
    //dash line
    CGContextStrokePath(context)
    CGContextMoveToPoint(context, width3, height3)
    CGContextAddLineToPoint(context, width33, height33)
    CGContextSetLineDash(context, 0, [4], 1)
    //next lines...
    CGContextMoveToPoint(context, width4, height4)
    CGContextAddLineToPoint(context, width44, height44)

我想在 width3 和 height3 上有虚线,但我的下一行也是虚线..如何停止要执行的虚线?

您可以像这样重置上下文:

CGContextSetLineDash(context, 0, nil, 0)