Tarvo Mäesepp Tarvo Mäesepp - 29 days ago 9
Swift Question

Adding UIVisualEffectView also over tab bar

I am trying to create modal popup with

as it's background. I want the
to be over the tab bar but I do not see the way to achieve it.

This is what I do but this is not the output I want:

var visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
visualEffectView.frame = self.view.bounds

//Also tried like this

This is pretty much what I am looking for:

enter image description here

So my question is, how should I add the
to be over tab bar also as a subView. I know I could make another viewController and present it as
but this is not a solution for me.

Answer Source

I reproduced the problem adding the visualEffectView to UITabBarController's main view. For non-translucent tab bar view controller views are not extended under it, so the height is shorter than you need.

To fix the problem change

visualEffectView.frame = self.view.bounds


visualEffectView.frame = self.tabBarController!.view.bounds