首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xCode - UIVisualEffectView动画

xCode - UIVisualEffectView动画
EN

Stack Overflow用户
提问于 2014-12-15 20:14:24
回答 1查看 1.7K关注 0票数 3

我在制作VisualEffetView动画时遇到了问题。下面是我声明它的代码。

代码语言:javascript
复制
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 )

代码语言:javascript
复制
[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)

EN

回答 1

Stack Overflow用户

发布于 2014-12-15 20:44:50

通过上面的理解,我认为你只需要重新设置效果视图的高度就可以实现你想要的效果。

在动画块中添加代码:

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

代码语言:javascript
复制
[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;
 }];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27483860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档