2016-10-22 24 views
0

如何在Swift中使用「setLineWidth」和「setLineJoin」屬性和CGContextSetTextDrawingMode?使用具有setLineWidth屬性的CGContextSetTextDrawingMode(drawRect函數)

override func drawRect(rect: CGRect) { 

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

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

} 

只有屬性(setLineWith和setLineJoin)不起作用。 它在一年前工作。但現在它不起作用。

回答

0

這個工作在斯威夫特3

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

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

謝謝!我沒有更新到最新版本的swift。現在它正在工作! –

+0

不客氣! – Rob

相關問題