Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipericieri/68e2894f3d4f7396b0fead2b1301020d to your computer and use it in GitHub Desktop.
Save felipericieri/68e2894f3d4f7396b0fead2b1301020d to your computer and use it in GitHub Desktop.
Adds a Block View to Window Root View Controller
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
// MARK: - Handling Application Background State
func applicationDidEnterBackground(_ application: UIApplication) {
let blockView = BlockView()
blockView.tag = 123
let rootViewController = window?.rootViewController
rootViewController?.view.addSubview(blockView)
}
func applicationWillEnterForeground(_ application: UIApplication) {
let blockViewTag = 123
let rootViewController = window?.rootViewController
let blockView = rootViewController?.view.viewWithTag(blockViewTag)
blockView?.removeFromSuperview()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment