出于某种原因,在尝试创建具有圆角的线时,所有其他属性都应用于此两个
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()
结果:
有什么建议吗?谢谢!