nicklockwood / FXBlurView

[DEPRECATED]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with trying to take a screenshot of a view with an FXBlurView on top.

Umar-M-Haroon opened this issue · comments

I have a section of my app that contains a blurred image, and if you try to save the image with the following code, the blur will result in lots of squares, which is not aesthetically appealing.

Here is the following code for taking the screenshot

{

    UIView *wholeScreen = self.pictureView;

    // define the size and grab a UIImage from it
    UIGraphicsBeginImageContextWithOptions(wholeScreen.bounds.size, wholeScreen.opaque, 0.0);
    [wholeScreen.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *screengrab = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(screengrab, nil, nil, nil);

}

Try capturing the screenshot using -[UIView drawViewHierarchyInRect:afterScreenUpdates:] instead.

Adding [wholeScreen.layer drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES]; fixes the issue. Closing now.