북마크 내 question 정확히 동일합니다.
자르기 뷰를 돌아 다니면서 이미지의 일부분을 올바르게 표시하고 있지만 스크롤 뷰 확대/축소를 다루는 작업이 진행 중입니다. 현재 imageview 및 일반 UIView UIScrollview, 다음 scrollview 외부 계층 및 내 사용자 지정 자르기 UIView 높은 수준에서 있습니다. 나는 접촉 방법도의 drawRect 주위에 드래그하고 처리하기 위해 구현 :
- (void)drawRect:(CGRect)rect {
// Drawing code
if(self.image == nil)
return;
CGPoint offset = scrollView.contentOffset;
clipRect = CGRectOffset(self.frame, offset.x, offset.y);
UIImage *croppedImage = [image croppedImage:clipRect];
CGContextRef ctx = UIGraphicsGetCurrentContext();
[croppedImage drawAtPoint:CGPointMake(0, 0)];
}
참고 : 내 자르기보기가있는 UIImageView의 후손 아니라, 다른보기에서 기본 이미지에 대한 참조 만에 UIView를합니다.
@implementation UIImage (Resize)
- (UIImage *)croppedImage:(CGRect)bounds {
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], bounds);
UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return croppedImage;
}
...
@end
나는 내가 동기화 내 자르기보기를 유지할 수 UIScrollViewDelegate 방법 몇 가지를 구현 스크롤 활동을 통과했습니다
는 "croppedImage"는있는 UIImage에 카테고리와 매우 간단하다. 확대/축소도 함께 전달되지만 언급 된대로 아직 원하는대로 작동하지 않습니다.
또 다른 참고 : 나는 안녕하세요 그냥 가지고 확실히 당신을 도울 수는
CGImageRef imageRef = CGImageCreateWithImageInRect([yourImage CGImage], bounds);
and
CGContextDrawImage(ctx, clipRect, imageRef);
출처
2010-04-21 13:08:51
wkw
과 동일 할 때마다이 가능해야한다 자른 영역으로 새로운있는 UIImage를 생성하는 시간을 낭비 할 필요는 생각하지 않습니다 한번보세요 : https://github.com/barrettj/BJImageCropper/network/members – RayofHope
안녕하세요,이 솔루션을 얻었습니까? 나는 똑같은 문제에 직면하고있다. – ScarletWitch
아래 이미지와 같이 자르기를 원할 경우 https://raw.github.com/yuyak/YKImageCropper/master/Example/screenshot.png 다음을 사용하십시오. https://github.com/yuyak/YKImageCropper – RayofHope