Last active
January 18, 2020 22:39
-
-
Save felipericieri/68e2894f3d4f7396b0fead2b1301020d to your computer and use it in GitHub Desktop.
Adds a Block View to Window Root View Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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