nicklockwood / FXBlurView

[DEPRECATED]
Other
4.94k stars 713 forks source link

- (UIImage *)snapshotOfUnderlyingView getting the wrong blurLayer. #137

Open Gocy015 opened 7 years ago

Gocy015 commented 7 years ago

Hi , I am currently using FXBlurView , i've notice a place where there could be a bug:

in FXBlurView.m , in - (UIImage *)snapshotOfUnderlyingView

- (UIImage *)snapshotOfUnderlyingView
{
    __strong FXBlurLayer *blurLayer = [self blurPresentationLayer];
    __strong CALayer *underlyingLayer = [self underlyingLayer];
    CGRect bounds = [blurLayer convertRect:blurLayer.bounds toLayer:underlyingLayer];

    self.lastUpdate = [NSDate date];
    CGFloat scale = 0.5;
    if (self.iterations)
    {
        CGFloat blockSize = 12.0/self.iterations;
        scale = blockSize/MAX(blockSize * 2, blurLayer.blurRadius);
        scale = 1.0/floor(1.0/scale);
    }
    CGSize size = bounds.size;
...
}

In this method , the blurLayer could be self.layer or self.layer.presentationLayer , however , the underlyingLayer will always be self.underlyingView.layer , the issue i'm having is that , when blurLayer is equal to self.layer.presentationLayer ,the bounds here is not correct, and since you access the blurRadius from self.layer , i assume that the first line of this method should be :

    __strong FXBlurLayer *blurLayer = [self blurLayer];

Or am i understanding this wrong ? Any help would be appreciated !

FlorianBasso commented 7 years ago

I had a huge bug with the blur effect and thanks to you @Gocy015 it is fixed ! Thanks !!

Gocy015 commented 7 years ago

@FlorianBasso , glad i can help !