Tocropviewcontroller: Schnelle Delegiertenmethode

Erstellt am 8. Juli 2017  ·  3Kommentare  ·  Quelle: TimOliver/TOCropViewController

Hallo, ich bin derzeit auf Swift 3 und habe einige Probleme mit der Erstellung eines kreisförmigen Crop View-Controllers über die Delegate-Methode. Kann mir bitte jemand seinen Code dafür zusammen mit den aufgerufenen Funktionen zeigen, die das neu zugeschnittene Bild enthalten. Vielen Dank!

question

Hilfreichster Kommentar

@srosman8026 zum Beispiel

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: {

        })
    }
}

Alle 3 Kommentare

@srosman8026 zum Beispiel

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: {

        })
    }
}

Ja! @drougojrom ist richtig! Dank dafür! :)

Am besten machen Sie auch ein Swift-Beispielprojekt...

@TimOliver , ich habe das separate schnelle Projekt, ein kleines, nur zur Demonstration. Kann es in das separate Repository hochladen oder in Ihr Projekt einfügen.

Dafür kann ich ein neues Thema eröffnen.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen