by IGRSoft

Drag, Rotate, Scale and Crop

209 Stars 57 Forks Last release: almost 2 years ago (1.0.8) MIT License 90 Commits 8 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

[The Project is not served, please, enjoy forward :)]

U can use Mantis



IGRPhotoTweaks is a swift 4.2 library allow to expand an interface to crop photos, based on PhotoTweaks. It can let user drag, rotate, scale the image, and crop it. You will find it mimics the interaction of Photos.app on iOS 9. :]

Build Status Pod Version Platform License

Contribute to Development Goals Here:

BTC: 16tGJzt4gJJBhBetpV6BuaWuNfxvkdkbt4

BCH: bitcoincash:qpcwefpxddjqzdpcrx6tek3uh6x9v7t8tugu30jvks

LTC: litecoin:MLZxuAdJCaW7LdM4sQuRazgdNvd8G2bdyt


IGRPhotoTweaksViewController is a base interface for YourPhotoTweaksViewController. IGRPhotoTweaksViewController offers all the operations to crop the photo, which includes translation, rotate and scale.

To use it,

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "showCrop" {

    let yourCropViewController = segue.destination as! YourPhotoTweaksViewController
    yourCropViewController.image = sender as! UIImage
    yourCropViewController.delegate = self;


is the func calls the edit done action.

is the func calls the cancel edit action.

self.changedAngel(value: radians)
is the func to set rotation angle.

self.setCropAspectRect(aspect: "9:16")
is the func to set aspect ratio for crop view.

is the func resets all previous aspect ratio.

is the func resets all previous actions.

Get the cropped image ```swift extension ViewController: IGRPhotoTweakViewControllerDelegate { func photoTweaksController(_ controller: IGRPhotoTweakViewController, didFinishWithCroppedImage croppedImage: UIImage) { self.imageView?.image = croppedImage _ = controller.navigationController?.popViewController(animated: true) }

func photoTweaksControllerDidCancel(_ controller: IGRPhotoTweakViewController) {
    _ = controller.navigationController?.popViewController(animated: true)

} ```

Setup IGRPhotoTweaks Controller ```swift

override func viewDidLoad() { super.viewDidLoad()

self.isAutoSaveToLibray = true


Setup/Control Angle

fileprivate func setupSlider() { self.angleSlider?.minimumValue = -Float(IGRRadianAngle.toRadians(45)) self.angleSlider?.maximumValue = Float(IGRRadianAngle.toRadians(45)) self.angleSlider?.value = 0.0 }

@IBAction func onChandeAngleSliderValue(_ sender: UISlider) { let radians: CGFloat = CGFloat(sender.value) self.changeAngle(radians: radians) }

Customize View ```swift

override open func setupThemes() { IGRCropLine.appearance().backgroundColor = UIColor.green IGRCropGridLine.appearance().backgroundColor = UIColor.yellow IGRCropCornerView.appearance().backgroundColor = UIColor.purple IGRCropCornerLine.appearance().backgroundColor = UIColor.orange IGRCropMaskView.appearance().backgroundColor = UIColor.blue IGRPhotoContentView.appearance().backgroundColor = UIColor.gray IGRPhotoTweakView.appearance().backgroundColor = UIColor.brown }

override open func customBorderColor() -> UIColor { return UIColor.red }

override open func customBorderWidth() -> CGFloat { return 2.0 }

override open func customCornerBorderWidth() -> CGFloat { return 4.0 }

override open func customCropLinesCount() -> Int { return 3 }

override open func customGridLinesCount() -> Int { return 4 }

override open func customCornerBorderLength() -> CGFloat { return 30.0 }

override open func customIsHighlightMask() -> Bool { return true }

override open func customHighlightMaskAlphaValue() -> CGFloat { return 0.3 }

## Example
IGRPhotoTweaks.xcodeproj -> IGRPhotoTweaks target


IGRPhotoTweaks is available on CocoaPods. Add the follwing to your Podfile:

```ruby pod 'IGRPhotoTweaks', '~> 1.0.0'

Alternatively, you can manually drag the

folder into your Xcode project.


Not works in Objective-C


If using with an existing UIImagePickerController, be sure to set

allowsEditing = NO
otherwise you may force the user to crop with the native editing tool before showing IGRPhotoTweaksViewController.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.