cro

CropPickerView

Image Crop View

Showing:

Popularity

Downloads/wk

0

GitHub Stars

58

Maintenance

Last Commit

2mos ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

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

aspectRatio (square)


// free
cropPickerView.aspectRatio = 0

// square
cropPickerView.aspectRatio = 1

// width : height = 1 : 2
cropPickerView.aspectRatio = 1 / 2

// width : height = 3 : 4
cropPickerView.aspectRatio = 3 / 4

// width : height = 4 : 3
cropPickerView.aspectRatio = 4 / 3

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, pikachu77769@gmail.com

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100