0

I wanted to present a UIViewController with blur background. I used the following code in ViewDidLoad()

self.view.backgroundColor = UIColor.clear        
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark)
let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
let blurEffectView = UIVisualEffectView(effect: vibrancyEffect)
blurEffectView.frame = self.view.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
blurEffectView.alpha = 0.0
self.view.addSubview(blurEffectView)
self.view.sendSubview(toBack: blurEffectView)

The background blur is working as expected whereas the UIViewController that has been presented has a white glow as its border. Would be really helpful if someone can guide me how to remove that. Attaching the screenshot for reference.

enter image description here

Manju Basha
  • 665
  • 1
  • 9
  • 29

1 Answers1

0

First, try removing the vibrancy effect and see if that does anything. I've had unexpected results with it in the past. But, really, the problem is that an underlying view is bleeding through the edges. Therefore, simply expand the size of the blur view so that the edges are not equal to the edges of the screen. Set the center point of the blur view equal to the center point of the presenting view controller and make the frame of the blur view 1.25x the size of the view controller's frame.

Let me know if that doesn't work for you and I'll show you how I achieved the same effect.

lurning too koad
  • 2,698
  • 1
  • 17
  • 47