10

我在扩展和收缩 UIEffectView 时遇到问题。它可以很好地膨胀,但当它收缩时,它会立即弹到它的最终高度并滑入适当的位置,在它的尾迹中留下微弱的活力效果。这是一个 gif 来说明问题。 http://i.imgur.com/Lh8q7m1.gif

项目布局

这发生在一个新的空白项目设置中,如下所示: 项目布局

这是动画代码:

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

}

4

1 回答 1

2

我认为您必须在动画块内设置调整大小的代码。试试这种方式:

[UIView animateWithDuration:1.5f
                 animations:^{
                     if(self._effectsHeight.constant == 50){
                        self._effectsHeight.constant = 500;
                     }else{
                        self._effectsHeight.constant = 50;
                          }
                 }];
于 2015-01-11T20:50:30.150 回答