2012-12-03 3 views

답변

1
- (UIImage *)captureCell { 

    //hide controls if needed 
CGRect rect = [yourTableCell bounds]; 

    UIGraphicsBeginImageContext(rect.size); 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [yourTableCell.layer renderInContext:context]; 
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return img; 

} 
+0

고마워요. –

1

그 같은 시도 :

UIGraphicsBeginImageContext(yourTableViewCellView.bounds.size); 
[yourTableViewCellView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

을 한 다음 데이터에 이미지를 저장할 수 있습니다 :

+0

감사합니다. –

2

이러한 방법을 사용합니다. 전화 만하면 UIImage *image = [cell screenshot];

- (UIImage *)screenshot 
{ 
    return [self screenshotForRect:self.bounds]; 
} 

- (UIImage *)screenshotForRect:(CGRect) rect 
{ 
    UIGraphicsBeginImageContext(rect.size); 
    [[UIColor clearColor] setFill]; 
    [[UIBezierPath bezierPathWithRect:rect] fill]; 
    CGContextRef ctx = UIGraphicsGetCurrentContext(); 
    [self.layer renderInContext:ctx]; 
    UIImage *anImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext();  
    return anImage; 
} 
+0

감사합니다. –

관련 문제