美文网首页
2018-07-23 视图模糊效果

2018-07-23 视图模糊效果

作者: 北你妹的风 | 来源:发表于2018-07-23 18:08 被阅读12次

这里使用原生的UIVisualEffectView来实现模糊效果。

self.blurView = [[UIVisualEffectView alloc] initWithFrame:self.view.bounds];模糊视图布满整个视图

UITapGestureRecognizer *tap =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];

 [self.blurView addGestureRecognizer:tap];//添加点击事件,把模糊视图移除掉

  [[UIApplication sharedApplication].keyWindow addSubview:self.blurView];//加入window

注意,这里并没有设置模糊效果,而是要在设置动画效果时设置模糊效果。这样会有简单的动画效果。

 [UIView animateWithDuration:0.5 animations:^(void){

            self.blurView.effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];//设置模糊效果

            self.blurView.alpha= 0.9;//设置模糊视图的透明度

 }];

相关文章

网友评论

      本文标题:2018-07-23 视图模糊效果

      本文链接:https://www.haomeiwen.com/subject/regjmftx.html