2014-01-21 3 views
1
-(void)drawJPEG 
{ 
    NSArray* objects = [[NSBundle mainBundle] loadNibNamed:@"View" owner:nil options:nil]; 

    UIView* mainView = [objects objectAtIndex:0]; 

    for (UIView* view in [mainView subviews]) { 
     if([view isKindOfClass:[UIImageView class]]) 
     { 
      UIImage* PassportSizePhoto = [UIImage imageNamed:@"1.jpeg"]; 
      [self drawImage:PassportSizePhoto inRect:view.frame]; 
     } 
    } 
    UIImage *image; 
    UIGraphicsBeginImageContext(mainView.bounds.size); 
    { 
     [mainView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
     image = UIGraphicsGetImageFromCurrentImageContext(); 
    } 
    UIGraphicsEndImageContext(); 
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 
} 
+1

여기에 어떤 문제가 있습니까? – Mani

+0

왜 jpeg 이미지를 사용하고 있습니까? 문제를 설명해 주실 수 있습니까? – Sierra

답변

-1

여기에 다른 사람들의 열심히 얻은 전문 지식을 간접적으로 활용하지 않으려면 이미 구운 코드를 기대하지 마십시오.

이미지에 대해 Apple의 설명서를 읽을 시간을 갖습니다.

  1. Apple 문서에서 UIImageJPEGRepresentation을 읽으십시오.
  2. 이미지를 필요한 크기로 조정하기 위해 Stack-overflow을 검색하십시오.

이것은 매우 간단하며 스택 오버플로에서 백만 번 요청되었습니다.

관련 문제