What is replace of the CGContextAddLineToPoint
this is what I’m trying to do
for i in aerr {
//0.5f offset lines up line with pixel boundary
CGContextMoveToPoint(context, self.bounds.origin.x, self.font!.lineHeight * CGFloat(x) + baselineOffset)
CGContextAddLineToPoint(context, CGFloat(self.bounds.size.width), self.font!.lineHeight * CGFloat(x) + baselineOffset)
}
and I’m getting the following error. I know they clearly mention using move(to:)
but how to use that?
‘CGContextMoveToPoint’ is unavailable: Use move(to:) instead
2
Answers
you can do it like this
In Swift, you can simply use directly from your
context
because it methods is part of CGContext.So
CGContextMoveToPoint(context, x, y)
will becontext.move(to:CGPoint(x, y))
As same as,
CGContextAddLineToPoint(context, x, y)
will becontext.addLine(to: CGPoint(x, y))
So your code will be