Tocropviewcontroller: Swift 委托方法

创建于 2017-07-08  ·  3评论  ·  资料来源: TimOliver/TOCropViewController

嗨,我目前使用 swift 3,并且在通过委托方法创建圆形裁剪视图控制器时遇到了一些问题。 有人可以向我展示他们这样做的代码以及包含新裁剪图像的调用函数。 非常感谢!

question

最有用的评论

例如@srosman8026

extension YourVC : TOCropViewControllerDelegate {
    func openCrop(image: UIImage) {
        let crop = TOCropViewController(croppingStyle: .circular, image: image)
        crop.delegate = self
        present(crop, animated: true, completion: nil)
    }

    func cropViewController(_ cropViewController: TOCropViewController, didCropToCircleImage image: UIImage, rect cropRect: CGRect, angle: Int) {
        cropViewController.dismiss(animated: true, completion: {
            self.updatePhoto(image: image)
        })
    }

    func cropViewController(_ cropViewController: TOCropViewController, didFinishCancelled cancelled: Bool) {
        cropViewController.dismiss(animated: true, completion: {

        })
    }
}

所有3条评论

例如@srosman8026

extension YourVC : TOCropViewControllerDelegate {
    func openCrop(image: UIImage) {
        let crop = TOCropViewController(croppingStyle: .circular, image: image)
        crop.delegate = self
        present(crop, animated: true, completion: nil)
    }

    func cropViewController(_ cropViewController: TOCropViewController, didCropToCircleImage image: UIImage, rect cropRect: CGRect, angle: Int) {
        cropViewController.dismiss(animated: true, completion: {
            self.updatePhoto(image: image)
        })
    }

    func cropViewController(_ cropViewController: TOCropViewController, didFinishCancelled cancelled: Bool) {
        cropViewController.dismiss(animated: true, completion: {

        })
    }
}

是的! @drougojrom是正确的! 感谢那! :)

最好也制作一个 Swift 示例项目......

@TimOliver ,我有一个单独的 swift 项目,一个小项目,仅用于演示。 可以将其上传到单独的存储库或添加到您的项目中。

我可以为此打开一个新问题。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

anuradhss picture anuradhss  ·  3评论

felipebonezi picture felipebonezi  ·  6评论

yarodevuci picture yarodevuci  ·  8评论

Snow-Tech picture Snow-Tech  ·  4评论

TimOliver picture TimOliver  ·  4评论