I am in a project that creates a custom 'Move and Scale' Controller from UIImagePickerController . (the controller appears if imagePickerController.allowsEditing=YES )
I want crop an UIImage in the crop rectangle, as shown in the image below.

And I made the code to set the contentInset .
self.selectedImageView.backgroundColor = [UIColor redColor]; CGRect cropRect = [SKPhotoCropFrameView getCropRectFromOrientation:self.photoCropOrientation]; CGRect aspectFitRect = AVMakeRectWithAspectRatioInsideRect(self.selectedImageView.image.size, self.selectedImageView.frame); CGFloat difference = fabsf(cropRect.size.height - aspectFitRect.size.height); self.contentInset = UIEdgeInsetsMake(difference/2, 0, difference/2 + 20, 0);
and here is the result.

The black region is the content area.
However, if I pinch this scrollView to increase, something will happen.

I think I need to do something on
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
to change content dynamically. How can i do this? Please help me:)
source share