Search code examples
iosswiftcgpath

'CGPathGetBoundingBox' has been replaced by property 'CGPath.boundingBox'


I am integrating a library which was written in early Swift. Since a compatible version of that library with Swift 4 is not available, I was removing the errors myself.
There is this line :

let pathBounds = CGPathGetBoundingBox(path.cgPath);  

which is giving the error :

'CGPathGetBoundingBox' has been replaced by property 'CGPath.boundingBox'

along with the warning :

'CGPathGetBoundingBox' was obsoleted in Swift 3 (CoreGraphics.CGPathGetBoundingBox)

What is it's replacement in Swift 4 ? There is a function boundingBox in CGPath class but I am not able to figure out how to use that.


Solution

  • Quite simple :

    path.cgPath.boundingBox