ios - UIVisualEffectView 模糊约束动画错误

标签 ios objective-c uiviewanimation uivisualeffectview

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

project layout

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

这是动画代码:

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

最佳答案

我认为你必须在动画 block 中设置调整大小的代码。试试这个方法:

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

关于ios - UIVisualEffectView 模糊约束动画错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27158625/

相关文章:

ios - 如何创建包含许多 NSMutableArray 的 NSMutableDictionary

ios - iCloud 中的 CoreData 和照片问题

Objective-C 输出参数的可空性

ios - 带有关键帧的动画出错

ios - 插入单元格时动画 UICollectionView 框架更改

ios - Swift 中的 UIView.animateWithDuration - iOS7 问题

ios - subview 如何识别父 View (iPhone)的设置属性?

objective-c - 与 CALayer 相关的奇怪崩溃日志

ios - 如何在viewForHeaderInSection中设置变量,然后在cellForRowAtIndexPath中使用它?

ios - 函数 'glReadPixels' 的隐式声明在 ios 8 上编译的 C99 中无效