FXBlurView icon indicating copy to clipboard operation
FXBlurView copied to clipboard

FXBlurView and animations

Open jaumard opened this issue 10 years ago • 6 comments

Hi,

I try to use your great class but i have problems with animations, I have a FXBlurView with a scrollView behind but when i use : [UIView animateWithDuration:1.5 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ [self.scrollView scrollRectToVisible:frame animated:NO]; } completion:NULL];

The blur effect doesn't show the good image. It take directly the result of the animation. Same if i try to animate the FXBlurView to the bottom to top or top to bottom, the blur take the result of the animation directly.

I use autolayout if it's matter. Can you help me with this ?

jaumard avatar Dec 19 '13 18:12 jaumard

Unfortunately it's not possible to use FXBlurView with animations in this way. It will work if you scroll the scrollView by setting the animated: argument to YES, but not using UIView animation. This has to do with the way that iOS updates views when animating.

nicklockwood avatar Dec 19 '13 19:12 nicklockwood

Ok thanks a lot for your answer, so i will remove blur effect because i need some animations with UIView animation.

jaumard avatar Dec 21 '13 10:12 jaumard

Hi, I had the same issue as well and my case is that I had a image slideshow using the UIView animation with the FXBlurView on top of it. When slideshow animation happens the blur view doesn't get its blur updated during the image change

Are you planning to implement this fix sometime in the future?

killmyrene avatar Jan 04 '14 05:01 killmyrene

It's not possible to fix this due to the way Core Animation works. The animations happens in a separate process, so I can't get snapshots of the intermediate frames. If you need this, you'll have to implement your animation using a timer.

nicklockwood avatar Jan 04 '14 14:01 nicklockwood

A quick replacement for the UIView animateWithDuration. On my case I have a UIImageView behind a FXBlurView:

- (void)startAnimating
{
    if (_displayLink) {
        [_displayLink invalidate];
    }
    _displayLink = [CADisplayLink displayLinkWithTarget:self
                                               selector:@selector(animate:)];

    [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}

- (void)animate:(CADisplayLink *)sender
{
    CFTimeInterval duration = sender.duration;

    self.imageView.frame = CGRectMake(0,  self.imageView.frame.origin.y + 800*duration, self.imageView.frame.size.width, self.imageView.frame.size.height);
}

I am quite confident this can be abstracted to a Category

RuiAAPeres avatar Mar 07 '14 16:03 RuiAAPeres

As I suspected this won't work with animation so I decided to implement my own animation, as mentioned by @RuiAAPeres. Anyway thanks for clarify the flow.

vinioliveira avatar Oct 01 '14 05:10 vinioliveira