CropPickerView 0.3.0

CropPickerView 0.3.0

Maintained by pikachu987, ‘pikachu987’.



  • By
  • pikachu987

CropPickerView

CI Status Version License Platform

Introduce

The Corner and Side buttons allow you to modify the position of the crop and UIScrollView to zoom the image. If the image is larger than the area of the UIScrollView, the image can be scrolled up and down, left and right, and if the image is smaller than the area of the UIScrollView, the image is always centered.

CropPickerController

If you want to see the CropPickerViewController that is created with CropView, see CropPickerController


CropPickerView

- - -
- -

Requirements

CropPickerView written in Swift 5.0. Compatible with iOS 8.0+

Installation

CropPickerView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CropPickerView'

Usage

Xib or Storyboard file

setting

image

image

done!




Code editor

import CropPickerView
let cropPickerView = CropPickerView()
self.view.addSubview(cropPickerView)

done!




Property

image

cropPickerView.image = image
cropPickerView.image(image, crop: CGRect(x: 50, y: 30, width: 100, height: 80), isRealCropRect: false)
cropPickerView.image(image, crop: CGRect(x: 50, y: 30, width: 100, height: 80), isRealCropRect: true)
cropPickerView.image(image, isMin: false, crop: CGRect(x: 50, y: 30, width: 100, height: 80), isRealCropRect: true)
cropPickerView.image(image, isMin: false)

color

cropPickerView.cropLineColor = UIColor.gray
cropPickerView.scrollBackgroundColor = UIColor.gray
cropPickerView.imageBackgroundColor = UIColor.gray
cropPickerView.dimBackgroundColor = UIColor(white: 0, alpha: 0.1)

zoom

cropPickerView.scrollMinimumZoomScale = 1
cropPickerView.scrollMaximumZoomScale = 2

radius

cropPickerView.radius = 50

cropSize

cropPickerView.cropMinSize = 200



Method

crop

cropPickerView.crop { (result) in
    if let error = (result.error as NSError?) {
        let alertController = UIAlertController(title: "Error", message: error.domain, preferredStyle: .alert)
        alertController.addAction(UIAlertAction(title: "Ok", style: .cancel, handler: nil))
        self.present(alertController, animated: true, completion: nil)
        return
    }
    self.imageView.image = result.image
}



Delegate

class ViewController: UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()

        let cropPickerView = CropPickerView()
        cropPickerView.delegate = self
    }
}

// MARK: CropPickerViewDelegate
extension ViewController: CropPickerViewDelegate {
    func cropPickerView(_ cropPickerView: CropPickerView, result: CropResult) {

    }

    func cropPickerView(_ cropPickerView: CropPickerView, didChange frame: CGRect) {
        print("frame: \(frame)")
    }
}

Author

pikachu987, [email protected]

License

CropPickerView is available under the MIT license. See the LICENSE file for more info.