使uiview模糊,它包含一个我想保持未模糊的自定义视图



我在视图控制器的默认视图中有1custom UIView
我的需要是,如果一个按钮被点击,我的默认主视图去模糊和自定义视图保持不变。
再次点击按钮,模糊视图恢复正常效果。
我使用UIBlurEffectUIVisualEffectView来制作模糊。
但问题是整个视图都模糊了。

我还没有尝试过效果视图,但它们看起来像是视图层次结构中的好公民。如果这是真的,那么这应该可以工作…

// assume aView is the view you want blurred, and
// aSubview is the view you want to remain unblurred 
[aSubview removeFromSuperview];
// apply the effect view to aView
[aView addSubview:aSubview];

应用到你的视图,只有你想使它模糊。试试吧:

UIVisualEffect *MyblurEffect;
MyblurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView;
visualEffectView = [[UIVisualEffectView alloc] initWithEffect:MyblurEffect];
visualEffectView.frame = MyVIEW.bounds;
[MyVIEW addSubview:visualEffectView]; //MyVIEW-> your view

试试这些链接:如何应用模糊到一个UIView?

最新更新