Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIVisualEffectView blur constraint animation bug

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];
                 }];

}

like image 989
Travis Beck Avatar asked Nov 26 '14 20:11

Travis Beck


1 Answers

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;
                          }
                 }];
like image 135
Totka Avatar answered Sep 22 '22 14:09

Totka