Ios xCode-UIVisualEffectView动画

Ios xCode-UIVisualEffectView动画,ios,xcode,animation,blur,uivisualeffectview,Ios,Xcode,Animation,Blur,Uivisualeffectview,我在设置VisualEffetView动画时遇到问题。 这是我声明它的代码 UIBlurEffect* blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; effectView = [[UIVisualEffectView alloc] initWithEffect:blur]; effectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAu

我在设置VisualEffetView动画时遇到问题。 这是我声明它的代码

UIBlurEffect* blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
effectView = [[UIVisualEffectView alloc] initWithEffect:blur];
effectView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
effectView.frame = self.bounds;
self.layer.borderWidth = 1;
[self addSubview:effectView];
当我为superview设置动画以使其增长时,视觉效果会跟随superview的动画,但当我想减少它时,视觉效果会立即消失,从而使结果非常难看^^ 下面是我制作superview动画的代码(这里称为recherche)

这是我让雷切消失时所拥有的。白色正方形似乎是效果视图,因为如果我更改UIFullEffectStyle,颜色会发生变化。但模糊效果缺失(x)

根据以上理解,我发现您只需重置效果视图的高度即可实现所需的效果

在动画块中添加了代码:

检查并让我知道,它是否完全满足您的期望

[UIView animateWithDuration:0.3f
                      delay:0.0f
                    options:UIViewAnimationOptionTransitionNone
                 animations:^{
     CGRect f = recherche.frame;
     f.size.height = 0;
     [recherche setFrame:f];

     // Add this lines
     CGRect effectViewFrame = effectView.frame;
     effectView.size.height = 0;
     effectView.frame = effectViewFrame;

 }
 completion:^(BOOL finished){
     [recherche removeFromSuperview];
     recherche = nil;
 }];

问题:您是否正在删除添加了effectView的视图的超级视图,对吗?这就是我在完成块中所做的。但只有模糊视图消失了。这就是为什么我要设置边界线。我用它来查看动画。即使在动画中,你也会将其高度设置为零。所以这没有意义,零高度不会显示superview。你想实现什么,你有任何截图或参考链接或一个例子添加在问题中,然后请更新它。我想隐藏superview,然后我把它的高度设置为0使它消失。我希望模糊效果也能起到同样的作用。当我显示superview时,它工作正常。现在我是空白的,您需要发布屏幕截图或gif动画来显示问题。我知道您想要实现什么。从这个git回购中获得帮助-
[UIView animateWithDuration:0.3f
                      delay:0.0f
                    options:UIViewAnimationOptionTransitionNone
                 animations:^{
     CGRect f = recherche.frame;
     f.size.height = 0;
     [recherche setFrame:f];

     // Add this lines
     CGRect effectViewFrame = effectView.frame;
     effectView.size.height = 0;
     effectView.frame = effectViewFrame;

 }
 completion:^(BOOL finished){
     [recherche removeFromSuperview];
     recherche = nil;
 }];