我在扩展和签约UIEffectView时遇到问题.它的扩展很好,但是当它收缩时,它会立即捕捉到最后的高度并滑动到位,留下微弱的活力效果.想要一个gif来说明问题.
http://i.imgur.com/Lh8q7m1.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];
}];
}
解决方法
我想你必须在动画块中设置调整大小的代码.这样做:
[UIView animateWithDuration:1.5f
animations:^{
if(self._effectsHeight.constant == 50){
self._effectsHeight.constant = 500;
}else{
self._effectsHeight.constant = 50;
}
}];