【发布时间】:2016-02-21 15:22:27
【问题描述】:
由于某种原因,当尝试创建圆角线时,所有其他属性都应用在这两个旁边
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()
结果:
有什么建议吗?谢谢!
【问题讨论】:
-
看起来,您的线延伸到整个 y 坐标范围 (0 .. bounds.maxY),因此任何线帽都将在边界之外 超出。
-
@MartinR,是的。谢谢。能否请您发布答案,以便我接受?
-
@RoiMulia 完美,谢谢。请注意,我在评论之前已经删除了忽略标签。
-
@JanGreve 感谢您通知我。以后会多关注我的标签
标签: ios swift cgcontext uigraphicscontext