Have a view cover entire screen except tab

295 Views Asked by At

I am currently trying to create a temporary view that covers the entire window of my app (except the tab bar) while the background threads loads the content. The way I am doing this is the following

 super.viewDidLoad()
 let window = UIApplication.shared.keyWindow!
 let v = UIView(frame: window.bounds)
 window.addSubview(v)

However, this creates a view that covers the tab bar. Is there a way to have a view cover the entire screen except the tab bar?

1

There are 1 best solutions below

0
matt On

Yes, if you are in a view controller where there is a tab bar (i.e. inside a UITabBarController interface), the top of the tab bar is the bottom of the safe area, so instead of setting the frame to window.bounds, adjust the height of the frame in accordance with where the bottom of the safe area insets are.