alexdrone / ios-realtimeblur

Multipurpose real-time blur view for iOS6+
MIT License
951 stars 107 forks source link

Change blur view position with animation #8

Open sarperdag opened 11 years ago

sarperdag commented 11 years ago

Looks like this doesn't work correct. Trying to build something like the control center in iOS7. So if I try to present a blur view modally from the bottom of the window, the blur view isn't real time. Just statically contains its background and doesn't change as it's animated.

Any ideas how to implement this?

marioEAE commented 11 years ago
    //take screenshot of current view
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    //Get blur from screenshot
    NSData *imageData = UIImageJPEGRepresentation(viewImage, kDRNRealTimeBlurViewScreenshotCompression);
    UIImage *image2 = [[UIImage imageWithData:imageData] drn_boxblurImageWithBlur:kDRNRealTimeBlurViewBlurRadius];

    //crop image to my rect
    CGRect cropRect = CGRectMake(0, [[UIScreen mainScreen] bounds].size.height - kSupporterHeight, kSupporterWidth, kSupporterHeight);
    CGImageRef imageRef = CGImageCreateWithImageInRect([image2 CGImage], cropRect);

    //init and hide image to animate entry
    _scrollViewBackgoundView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:imageRef]];
    [_scrollViewBackgoundView setFrame:CGRectMake(0, screenRect.size.height, kSupporterWidth, kSupporterHeight)];
    [self.view addSubview:_scrollViewBackgoundView];
marioEAE commented 11 years ago

This was my workaround, i also had the same problem... (you can check on closed issues)

sarperdag commented 11 years ago

Yeah we implemented a similar solution too and now it's working. Thanks for the help!

Sarp Erdag Sent from my iPhone

On 26 July 2013 Friday at 14:44, marioEAE wrote:

This was my workaround, i also had the same problem... (you can check on closed issues)

— Reply to this email directly or view it on GitHub (https://github.com/alexdrone/ios-realtimeblur/issues/8#issuecomment-21615801).

jvicjvic commented 11 years ago

I've got a different animation scenario that i think it's not solved by this workaround. It's this:

When i move the blurred view with UIView animations, the blur doesn't get updated while it's animating. I think it's possible to do that but i haven't found a way out. How can it know it's inside an UIView animation, and update its content? Anybody got suggestions?

Thanks.