[英]CGContextSetLineDash is unavailable
CGContextSetLineDash(context, 0, [2, 2], 2)
使用上面的代碼行,我得到了錯誤:
CGContextSetLineDash不可用:使用setLineDash(self:phase:lengths :)
我嘗試了CGContext.setLineDash
無濟於事,有什么建議嗎?
setLineDash
不是靜態/類方法,它是一個實例方法:
context.setLineDash(phase: 0, lengths: [2, 2])
在Swift 3中,CGContext是具有實例方法的偽對象。
因此,例如:
class V : UIView {
override func draw(_ rect: CGRect) {
let c = UIGraphicsGetCurrentContext()!
c.setLineDash(phase: 0, lengths: [2,2])
// ...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.