[英]CGContextSetLineDash is unavailable
CGContextSetLineDash(context, 0, [2, 2], 2)
With the above line of code I get the error: 使用上面的代码行,我得到了错误:
CGContextSetLineDash is unavailable: Use setLineDash(self:phase:lengths:) CGContextSetLineDash不可用:使用setLineDash(self:phase:lengths :)
I've tried CGContext.setLineDash
to no avail, any suggestions? 我尝试了CGContext.setLineDash
无济于事,有什么建议吗?
setLineDash
不是静态/类方法,它是一个实例方法:
context.setLineDash(phase: 0, lengths: [2, 2])
In Swift 3, a CGContext is a pseudo-object with instance methods. 在Swift 3中,CGContext是具有实例方法的伪对象。
Thus, for example: 因此,例如:
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.