Search code examples
swiftxcodecocoapodscrop

crop an image getting error


I am trying to implement a cropping pod to my Xcode project.

I am getting this error and i am not sure why.

can anyone help.

   let imageRef = imageToCrop!.cgImage!.cropping(to: visibleRect)
    let result = UIImage(CGImage: imageRef!, scale: imageToCrop!.scale,
        orientation: imageToCrop!.imageOrientation)

    return result
}

but getting this error

Ambiguous use of 'init(CGImage:scale:orientation:)'


Solution

  • It is init(cgImage:scale:orientation:) not init(CGImage:scale:orientation:).

    let result = UIImage(cgImage: imageRef!, scale: imageToCrop!.scale, orientation: imageToCrop!.imageOrientation)