Search code examples
swiftswift3core-graphicscgpath

convert CGPathAddArcToPoint to Swift 3


I upgraded to Swift 3 and I'm having an impossible time finding tips online to fix this. I was able to research move and add a line but not this one.

CGPathAddArcToPoint(bubblePath, nil,
    bubbleRect.origin.x+bubbleRect.size.width, bubbleRect.origin.y, 
    bubbleRect.origin.x+bubbleRect.size.width, bubbleRect.origin.y+self.cornerRadius,
    self.cornerRadius)

Here is my original code but I have no idea how to convert it. I'm pretty sure I need to use addArc but that is the extent of my research.

Can someone please help me?


Solution

  • This is now a method and not a loose global function (as quoted in this related question), so the way you'd need to do this should be something like:

    let bubblePath = CGMutablePath.init()
    let point1 = CGPoint(x: bubbleRect.origin.x+bubbleRect.size.width, y: bubbleRect.origin.y)
    let point2 = CGPoint(x: bubbleRect.origin.x+bubbleRect.size.width, y: bubbleRect.origin.y+self.cornerRadius) 
    bubblePath.addArc(tangent1End: point1, tangent2End: point2, radius: self.cornerRadius)