Adjust intensity of blur effect inside UIVisualEffectView in Swift

I use this code to create a blur effect inside my view:

let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light)) blur.frame = CGRectMake(180, 10, 200, 750) myView.addSubview(blur) 

is there a way to customize the blurring gauss function to achieve different levels of the out-of-focus effect?

+8
swift gaussian uivisualeffectview uiblureffect blurry
source share
2 answers

Since there is no other parameter in UIBlurEffect , I think the only way is to use the CIFilter CIGaussianBlur prefix to blur the background image and use its inputRadius key to adjust the level.
If you want to achieve the same effect as the so-called light / dark / ExtraLight , you can create this filter with other filters.

+1
source share

The radius of the actual UIBlurEffect cannot change, but there is a workaround.

Changing the alpha component of a UIVisualEffectView will give a subtle blur effect.

 let blur = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Light)) blur.frame = CGRectMake(180, 10, 200, 750) blur.alpha = 0.4 myView.addSubview(blur) 

Swift 3

 let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.extraLight) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.alpha = 0.4 blurEffectView.frame = self.bounds self.addSubview(blurEffectView) 
+1
source share

All Articles