裁剪图像出现错误

crop an image getting error

我正在尝试为我的 Xcode 项目实施裁剪荚。

我收到这个错误,我不确定为什么。

谁能帮忙。

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

    return result
}

但收到此错误

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

init(cgImage:scale:orientation:)不是init(CGImage:scale:orientation:)

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