将 CGContextSetTextDrawingMode 与 setLineWidth 属性(drawRect 函数)一起使用

Using CGContextSetTextDrawingMode with setLineWidth property (drawRect function)

如何在 Swift 中将 "setLineWidth" 和 "setLineJoin" 属性与 CGContextSetTextDrawingMode 一起使用?

override func drawRect(rect: CGRect) {

    let context = UIGraphicsGetCurrentContext()
    CGContextSetTextDrawingMode(context, CGTextDrawingMode.Stroke)

    context?setLineWidth(2)
    context.setLineJoin(CGLineJoin.Round)

}

只有属性(setLineWith 和 setLineJoin)不起作用。 它在一年前工作。但是现在不行了。

这适用于 Swift 3

let context = UIGraphicsGetCurrentContext()
    context!.setTextDrawingMode(CGTextDrawingMode.stroke)

    context?.setLineWidth(2.0)
    context?.setLineJoin(.round)