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?
Yes, if you are in a view controller where there is a tab bar (ie 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.