2015-06-05 16 views
0

這是我的代碼:斯威夫特 - UIGraphics虛線接近

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破折號,但我的下一行也被破滅。如何停止虛線被執行?

+0

你可以嘗試將其復位這樣的:'CGContextSetLineDash(背景下,0,NULL,0)' –

+0

哦,是的,當然:) –

回答

2

您可以重置這樣的背景下:

CGContextSetLineDash(context, 0, nil, 0)