10

I'm having an issue expanding and contracting a UIEffectView. Its expands fine, but when it contracts it instantly snaps to its final height and slides into position, leaving behind a faint vibrancy effect in its wake. Heres a gif to illustrate the problem. http://i.imgur.com/Lh8q7m1.gif

project layout

This happens in a new blank project setup as so: project layout

Here is the animation code:

- (IBAction)toggleEffects:(id)sender {
[self.view setNeedsLayout];

if(self._effectsHeight.constant == 50){
    self._effectsHeight.constant = 500;
}else{
    self._effectsHeight.constant = 50;
}
[UIView animateWithDuration:1.5f
                 animations:^{
                     [self.view layoutIfNeeded];
                 }];

}

Travis Beck
  • 1,128
  • 9
  • 21
  • I'm seeing the exact same thing. Looks like a bug to me. I filed a bug with Apple Bug Reporter, no# 19187042 – Robert Wagstaff Dec 09 '14 at 06:26
  • I was able to fix it by adding the effects view as a subview of a masking view. The effects view is setup as having the full height you intend for the animation to end at and you animate the height of the masking view to reveal the effects view beneath. – Travis Beck Dec 10 '14 at 05:18
  • Could you add border around the view in order to examine it's frame, and post another GIF? – wczekalski Dec 14 '14 at 10:44
  • I added the project to github so you can see how its setup:https://github.com/travisjbeck/uivieweffectsanimationtest – Travis Beck Dec 14 '14 at 17:28
  • have you tried turning it off and on again? – C Jones Dec 16 '14 at 03:45
  • I have a similar problem. I'm animating by frames. The appearing animation from bottom to top over an image view works fine. However as soon as I try to animate from top to bottom, the blur is gone (in the first animation frame) and instead a 0.5 alpha is shown – no matter how the view hierarchy is constructed. – DrMickeyLauer Dec 23 '14 at 19:14

1 Answers1

2

I think that you have to set the resizing code inside the animation block.Try this way:

[UIView animateWithDuration:1.5f
                 animations:^{
                     if(self._effectsHeight.constant == 50){
                        self._effectsHeight.constant = 500;
                     }else{
                        self._effectsHeight.constant = 50;
                          }
                 }];
Totka
  • 627
  • 6
  • 24