CGContextSetLineDash(context, 0, [2, 2], 2)
With the above line of code I get the error:
CGContextSetLineDash is unavailable: Use setLineDash(self:phase:lengths:)
I've tried CGContext.setLineDash
to no avail, any suggestions?
setLineDash
不是静态/类方法,它是一个实例方法:
context.setLineDash(phase: 0, lengths: [2, 2])
In Swift 3, a CGContext is a pseudo-object with instance methods.
Thus, for example:
class V : UIView {
override func draw(_ rect: CGRect) {
let c = UIGraphicsGetCurrentContext()!
c.setLineDash(phase: 0, lengths: [2,2])
// ...
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.