나는 그것을 얻을 관리했습니다.
- (UIImage *)imageByCropping:(UIScrollView *)imageToCrop toRect:(CGRect)rect
{
CGSize pageSize = rect.size;
UIGraphicsBeginImageContext(pageSize);
CGContextRef resizedContext = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(resizedContext, -imageToCrop.contentOffset.x, -imageToCrop.contentOffset.y);
[imageToCrop.layer renderInContext:resizedContext];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
사용하여 전화 : 도움이되었다
CGRect clippedRect = CGRectMake(0, 0, 320, 300);
picture.image = [self imageByCropping:myScrollView toRect:clippedRect];
, 감사
다음은 웹에서 몇 가지 다른 것들에 따라 내 솔루션입니다. 비록 메소드에 약간의 버그가 있습니다. scrollView를 참조합니다. 호출자가 "scrollView"뷰의 이름을 지정하지 않을 경우 대신 imageToCrop을 참조해야합니다. –
당신은 완전히 맞습니다 :) 당신이 유용하다고 생각해서 다행입니다. 건배 – Andre
이것은 매우 유용합니다! 감사합니다. Andre – Ganesh