Skip to content

TalDabush/CropPickerView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CropPickerView

Version License Platform Swift 5.0

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.

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 = UIImage(named: "")

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



Method

crop

cropPickerView.crop { (error, image) in
    if let error = (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 = 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, error: Error) {

    }
    func cropPickerView(_ cropPickerView: CropPickerView, image: UIImage) {

    }
}

Author

pikachu987, [email protected]

License

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

About

Image Crop View

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.7%
  • Ruby 2.3%