0

Since iOS 8 Apple provided easier way to make blur. But can i animate its appearance?

 CSDTimelineCell* headerCell = (CSDTimelineCell*)[self.timelineTabel cellForRowAtIndexPath:self.headerIndexPath];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *bluredEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[bluredEffectView setFrame:headerCell.bounds];
[bluredEffectView setHidden: YES];
[headerCell addSubview:(UIView *)bluredEffectView];
[UIView transitionWithView:bluredEffectView
                  duration:3
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    bluredEffectView.hidden = NO;
                } completion:nil];

Setting 0 alpha value is deprecated for this class. Any suggestions?

1 Answers1

1

UIVisualEffectView is a hack in the Apple framework. It's not an overlapping layer, it completely replaces the layers behind itself by processing them. It won't be possible to change its alpha.

However, it should be possible to use UIViewAnimationOptionTransitionCrossDissolve transition but you have to use it correctly. The transition takes a snapshot of a view before changes then takes a snapshot of a view after changes and then animates the difference. You need to give it a view that encompasses all the changes:

[UIView transitionWithView:headerCell
                  duration:3
                   options:UIViewAnimationOptionTransitionCrossDissolve
                animations:^{
                    bluredEffectView.hidden = NO;
                } completion:nil];

(I haven't tested this but it might work)

Sulthan
  • 128,090
  • 22
  • 218
  • 270