1

I need to add a blur view to my app.

I've tried UIBlurEffect but there are just 3 option (Light, Dark, ExtraLight), and I need something between Light and Dark.

I understood the only option I have is to create a custom blur view, but how can I do that?

Any idea?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
FS.O5
  • 297
  • 1
  • 4
  • 13

1 Answers1

3

Here is an easy way out if you are using a storyboard. First you need to add a "Visual Effect View with Blur" from storyboard right above where your image,UIUiew or uielement is to be seen. Now draw the outlet of the Visual effect view as follows:-

 @IBOutlet weak var blurredViewVisulaEffect: UIVisualEffectView!

and add these two lines in the viewDidLoad method

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
blurredViewVisulaEffect.effect = blurEffect

MANIPULATION of the view to make it according to our requirement:- Now if you want to customise the blurriness of the image, then change the value of alpha of UIVisualEffectView from storyboard.Keep the value of Alpha within 0.5 to 0.8 to obtain desired blurriness. And if you want to change the shade/color of the view, as mentioned by you between light and dark then you need to set the background color of your UIVisualEffectView to black and change its opacity from 100% to 30%(or may be 40 as required).

Ishika
  • 2,187
  • 1
  • 17
  • 30