Skip to content

Commit

Permalink
Fix behavior when using freeStyleCropEnabled and setup proper crop …
Browse files Browse the repository at this point in the history
…aspect ratio by calculating `width` and `height`
  • Loading branch information
sergioutama committed May 8, 2020
1 parent f775b50 commit 68b9cf0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ios/src/ImageCropPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,17 @@ - (void)cropImage:(UIImage *)image {
cropVC = [[TOCropViewController alloc] initWithCroppingStyle:TOCropViewCroppingStyleCircular image:image];
} else {
cropVC = [[TOCropViewController alloc] initWithImage:image];
CGFloat widthRatio = [[self.options objectForKey:@"width"] floatValue];
CGFloat heightRatio = [[self.options objectForKey:@"height"] floatValue];
if (widthRatio > 0 && heightRatio > 0){
CGSize aspectRatio = CGSizeMake(widthRatio, heightRatio);
cropVC.customAspectRatio = aspectRatio;

}
cropVC.aspectRatioLockEnabled = ![[self.options objectForKey:@"freeStyleCropEnabled"] boolValue];
cropVC.resetAspectRatioEnabled = !cropVC.aspectRatioLockEnabled;
}

cropVC.title = [[self options] objectForKey:@"cropperToolbarTitle"];
cropVC.delegate = self;

Expand Down

0 comments on commit 68b9cf0

Please sign in to comment.