Overlay a view over whole screen, when using UITabBarController?

后端 未结 5 575
渐次进展
渐次进展 2021-02-08 02:13

I want to overlay a HUD-style transparent graphic over the entire screen in a UITabBarController setup. The button to do this is in the first tab\'s screen (FirstViewController)

5条回答
  •  爱一瞬间的悲伤
    2021-02-08 02:41

    I really liked what Chase Robert had written here, so I thought to provide the Swift 3. version as well:

        if let window = view.window {
            let subView = UIView(frame: window.frame)
            window.addSubview(subView)
        }
    

    I added the condition as well, so you don't get a crash if there's no windows.

提交回复
热议问题