我在制作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];当我动画超级视图使其增长时,视觉效果遵循超级视图的动画,但当我想减少它时,视觉效果立即消失,使结果非常丑陋^^这是我动画超级视图的代码(这里称为recherche )
[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationOptionTransitionNone
animations:^{
CGRect f = recherche.frame;
f.size.height = 0;
[recherche setFrame:f];
}
completion:^(BOOL finished){
[recherche removeFromSuperview];
recherche = nil;
}];这是当我让recherche消失时我所拥有的。白色方块看起来像是效果视图,因为如果我更改UIBlurEffectStyle,颜色就会改变。但模糊效果缺少x)

发布于 2014-12-15 20:44:50
通过上面的理解,我认为你只需要重新设置效果视图的高度就可以实现你想要的效果。
在动画块中添加代码:
检查并让我知道,它是否完全满足您的期望。
[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;
}];https://stackoverflow.com/questions/27483860
复制相似问题