artemkrachulov / AKImageCropperView

Responsive image cropper
MIT License
172 stars 66 forks source link

how can I lock the aspect ratio? #8

Open nalogowiec opened 7 years ago

nalogowiec commented 7 years ago

Is there a way of locking aspect ration of cropper, e.g. to 2:3 or 9:16?

tmichele commented 7 years ago

I'm interested too!

geovannyAndrew commented 7 years ago

I need it too. Thanks.

ayrtonsoftware commented 7 years ago

Me 3..... aspect ratio...... of the cropper ....

rodtaborda commented 7 years ago

Did you find any solution?

ritika1159 commented 7 years ago

Any solution for locking the aspect ratio ?

geovannyAndrew commented 7 years ago

I had to modify the library code. I added two vars: ratioX and ratioY in AKImageCropperOverlatView.swift file, I changed the method touchesMoved in this class, and added the method fixedRatio(ratioX:CGFloat,ratioY:CGFloat) for set vars, I had to change some methods in AKImageCropperView.swift from fileprivate to open. These changes worked for my requeriments project. I hope to help. Thanks. My example implementation was:

override func viewDidLoad() { navigationController?.isNavigationBarHidden = true cropViewOutlet.image = image cropViewOutlet.delegate = self; cropViewOutlet.overlayView?.cropRect.origin.y = 100 cropViewOutlet.showOverlayView(animationDuration: 0.3) cropViewOutlet.overlayView?.fixedRatio(ratioX: 6, ratioY: 5) }

AKImageCropperView.zip

AwaisFayyaz commented 3 years ago

I also need it