Commit 2f626ac0 authored by yuzheng's avatar yuzheng

修复横屏裁剪时图片位置不对的问题

parent 9e6af874
......@@ -325,15 +325,15 @@
if (_allowCrop) {
// 1.7.2 如果允许裁剪,需要让图片的任意部分都能在裁剪框内,于是对_scrollView做了如下处理:
// 1.让contentSize增大(裁剪框右下角的图片部分)
CGFloat contentWidthAdd = self.scrollView.tz_width - CGRectGetMaxX(_cropRect);
CGFloat contentHeightAdd = (MIN(_imageContainerView.tz_height, self.tz_height) - self.cropRect.size.height) / 2;
CGFloat newSizeW = self.scrollView.contentSize.width + contentWidthAdd;
CGFloat newSizeH = MAX(self.scrollView.contentSize.height, self.tz_height) + contentHeightAdd;
CGFloat contentWidthAdd = (MIN(_imageContainerView.tz_width, self.scrollView.tz_width) - _cropRect.size.width) / 2;
CGFloat contentHeightAdd = (MIN(_imageContainerView.tz_height, self.scrollView.tz_height) - _cropRect.size.height) / 2;
CGFloat newSizeW = MAX(self.scrollView.contentSize.width, self.scrollView.tz_width) + contentWidthAdd;
CGFloat newSizeH = MAX(self.scrollView.contentSize.height, self.scrollView.tz_height) + contentHeightAdd;
_scrollView.contentSize = CGSizeMake(newSizeW, newSizeH);
_scrollView.alwaysBounceVertical = YES;
// 2.让scrollView新增滑动区域(裁剪框左上角的图片部分)
if (contentHeightAdd > 0 || contentWidthAdd > 0) {
_scrollView.contentInset = UIEdgeInsetsMake(contentHeightAdd, _cropRect.origin.x, 0, 0);
_scrollView.contentInset = UIEdgeInsetsMake(contentHeightAdd, contentWidthAdd, 0, 0);
} else {
_scrollView.contentInset = UIEdgeInsetsZero;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment