0

I tried this code on an image to blur it ... using TViOS 10.1 and Swift 3.0

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.extraLight)
let blurView = UIVisualEffectView(effect: blurEffect)
blurView.frame = CGRect(x: 256, y: 128, width: 1024, height: 512)
self.view.addSubview(blurView)

With this result... sorry this is not a blur... I am missing something here?

enter image description here

user3069232
  • 8,587
  • 7
  • 46
  • 87
  • 2
    Possible duplicate of [How to edit the UIBlurEffect intensity?](http://stackoverflow.com/questions/28140781/how-to-edit-the-uiblureffect-intensity) – UpSampler Feb 03 '17 at 14:26
  • 1
    try playing with the `blurView.layer.opacity`'s __[value](https://developer.apple.com/reference/quartzcore/calayer/1410933-opacity)__, I think that could present options for you. – holex Feb 03 '17 at 14:28
  • Change the EffectStyle to .light. There are three choices, and my experiments with opacity failed a while back and since then found some who say do not try that. If you don't like the three choices offered, you can always use CoreImage. Fairly simple code - when applied to the image. If you need that code, let me know. –  Feb 03 '17 at 14:43

2 Answers2

3

Your code is right, Default blur view in iOS is work like this. You want more light blur view, then you should use any third party frameworks.

I used this code in my project:

@IBOutlet var blurView: UIVisualEffectView!

override func viewDidLoad() {
    super.viewDidLoad()

    let blurEffect = UIBlurEffect(style: .extraDark)
    self.blurView.effect = blurEffect   
}

And the result is: enter image description here

anas.p
  • 2,246
  • 19
  • 26
  • Please explain to the OP *why* this works where the OP code didn't. It makes for a good answer. –  Feb 03 '17 at 15:29
  • Ok, but where is the blur? – user3069232 Feb 03 '17 at 16:09
  • Background of this screenshot is a blur view. The image shown in this screenshot is used as background image, and set a blur view above the background image. All the objects are placed on above the blur view. – anas.p Feb 04 '17 at 03:05
0

func blurEffect(){

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
    let blurEffectView = UIVisualEffectView(effect: blurEffect)
    blurEffectView.frame = self.blurView.bounds
    blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    self.blurView.addSubview(blurEffectView)

}

raheem
  • 17
  • 4