nicklockwood / FXBlurView

[DEPRECATED]
Other
4.94k stars 713 forks source link

FXBlurView and animations #33

Open jaumard opened 10 years ago

jaumard commented 10 years ago

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 ?

nicklockwood commented 10 years ago

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.

jaumard commented 10 years ago

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

killmyrene commented 10 years ago

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?

nicklockwood commented 10 years ago

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.

RuiAAPeres commented 10 years ago

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

vinioliveira commented 10 years ago

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.