X $ C $Ç - UIVisualEffectView动画 [英] xCode - UIVisualEffectView animating
问题描述
我有一个问题,而动画效果VisualEffetView。
这里是code,其中我宣布它。
I've an issue while animating a VisualEffetView. Here is the code where I declare it.
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];
在我的动画向上海华让它成长,在视觉效果上遵循上海华的动画,但是当我想减少它,视觉效果瞬间消失使结果非常难看^^
这里是code,我的动画的SuperView(这里叫做RECHERCHE)
When I animate the superview to make it grow, the Visual Effect follow the animation of the superview, but when I want to reduce it, the Visual Effect disappear instantly making the result very ugly ^^ Here is the code where I animate the superview (called recherche here)
[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)
Here is what I have when I make recherche disappear. The white square seems to be the Effect View because the color changes if I change the UIBlurEffectStyle. But blurring effect is missing x)
推荐答案
从上述认识,我弄清楚,你只需要重置效应鉴于高度达到你想要的东西。
From above understanding, I figure out that you just need to reset height of effect view to achieve what you want.
加code在动画块:
检查,让我知道,这是完全填补你的期望。
Check and let me know, is it full fill your expectation.
[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;
}];
这篇关于X $ C $Ç - UIVisualEffectView动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!