Open brandonscript opened 9 years ago
I've had a quick look at the AnimatedBlurExample and ViewController.m
uses UIView for the animation.
Eg.
[UIView animateWithDuration:0.5 animations:^{
self.blurView.blurRadius = 40;
}];
(you're using FXBlurView animateWithDuration: ...
)
Oh, yeah, @roycable it doesn't make a difference one way or the other. I had just tried to see if calling the method on the subclass would make a difference.
It's because you are calling the animation immediately after inserting the subview. This is a known bug/feature in Core Animation that animations don't work if they are applied to a view before it has appeared on screen.
The workaround is to delay your animation by a single frame, which you can do like this:
_blurEffectView = [[FXBlurView alloc] initWithFrame:self.superview.bounds];
_blurEffectView.tintColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
[self.superview insertSubview:_blurEffectView belowSubview:self];
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.5 animations:^{
_blurEffectView.blurRadius = 30;
}];
})
Yeah, it's a bit hacky, but hey, Objective-C ;-)
Hrm.. goofy, and it seems to work (albeit really choppy) when going from say, radius=30 to radius=5. But going from no blur to 30, it's still instant. Will play around some more - thanks for the tip!
Grabbing main queue sticks my entire UI
The solution that @nicklockwood posted technically works for me but it looks terrible. It is very glitchy/choppy looking. Will report back if I find a way to smooth out the animation of blurRadius.
@mitchellporter I'm seeing the same issue. Did you end up finding a smoother way?
@datwelk Nope I never found a solution. I ended up ditching the blur effect all together.
Not really sure what I'm doing wrong, but no matter what I do, the animation never fires - it just blurs instantly. Code looks like this: