drawInRect에서 UIImageview
을 집기, 이동 또는 회전 할 때 변환이 유지되지 않는 경우 문제가 발생했습니다.drawInRect가 UIImageView 변환을 읽지 않거나 유지하지 않습니다.
어떻게 drawInRect에서 변환을 보존 할 수 있습니까?
나는 모든 의견이 크게 감사합니다- (UIImage*) combineImage:(UIImageView *)selectedImage withOverlay:(UIImageView *)overlayImage
{
/* Identify the region that needs to be cropped */
CGRect viewForImgFrame = self.viewForImg.frame;
NSLog(@"view %@", NSStringFromCGRect(viewForImgFrame));
NSLog(@"selectedImage Img value %@",selectedImage);
NSLog(@"overlayImage Img value %@",overlayImage);
CGSize newImageSize =self.viewForImg.frame.size;
NSLog(@"CGSize %@",NSStringFromCGSize(newImageSize));
UIGraphicsBeginImageContextWithOptions(newImageSize, NO, 0.0); //retina res
//[self.viewForImg.layer renderInContext:UIGraphicsGetCurrentContext()];
[selectedImage.image drawInRect:CGRectMake(0, 0, selectedImage.frame.size.width, selectedImage.frame.size.height)];
CGContextConcatCTM(UIGraphicsGetCurrentContext(), overlayImage.transform);
[overlayImage.image drawInRect:CGRectMake(overlayImage.frame.origin.x, overlayImage.frame.origin.y, overlayImage.frame.size.width, overlayImage.frame.size.height)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
NSData *imgData = UIImageJPEGRepresentation(image, 0.9); //UIImagePNGRepresentation (image); // get JPEG representation
UIImage * imagePNG = [UIImage imageWithData:imgData]; // wrap UIImage around PNG representation
UIGraphicsEndImageContext();
return imagePNG;
}
이 있지만 이동을 :(했습니다.
전체'drawRect :'메소드 구현을 보여주십시오. – trojanfoe
안녕하세요 트로이 호프, 업데이트 됨 – Desmond