2013-10-03 7 views
0

이 코드iOS7에 스크린 샷

- (UIImage *)screenshot { 
    UIGraphicsBeginImageContext(self.bounds.size); 
    [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return image; 
} 

와 함께 스크린 샷을 복용하고있어 고려 흐림 효과를 고려하지 있지만 결과 이미지는 알파를 가지고 해결하기 위해 제대로

있는 방법을 보여주는 효과를 흐리게하지 않습니다 이?

답변

2

"renderInContext"의 문서를 살펴보면 애니메이션과 관련하여 몇 가지 단점이 있다는 것을 알 수 있습니다. 직접 레이어의 스크린 샷을 찍을 필요가없는 경우이 방법을 사용해보세요.

- (UIImage *)screenshot { 
    UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, 0); 
    [self.view drawViewHierarchyInRect:self.view.frame afterScreenUpdates:NO]; 
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext(); 
    return newImage; 
}