创建ImageContext时忽略CGContextSetLineCap / CGContextSetLineJoin

时间:2016-02-21 15:22:27

标签: ios swift cgcontext uigraphicscontext

出于某种原因,在尝试创建具有圆角的线时,所有其他属性都应用于此两个

 UIGraphicsBeginImageContextWithOptions(size, opaque, scale)
        let context = UIGraphicsGetCurrentContext()
            CGContextSetStrokeColorWithColor(context, color.CGColor)
            CGContextSetLineCap(context, CGLineCap.Round) //Ignored
            CGContextSetLineJoin(context, CGLineJoin.Round) //Ignored
            CGContextSetLineWidth(context, lineWidth)
        CGContextSaveGState(context)

        CGContextMoveToPoint(context, bounds.midX, 0)
        CGContextAddLineToPoint(context, bounds.midX, bounds.maxY)
        CGContextRestoreGState(context)
        CGContextStrokePath(context)

         // Drawing complete, retrieve the finished image and cleanup
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()

结果:

enter image description here

有什么建议吗?谢谢!

0 个答案:

没有答案