You all might know that iOS takes a screen shot of your application before throwing it into the background. This is usually for a better User experience like quick animation
swift 4.0 version.
for use custom icon
first add this line at top of AppDelegate
var imageView: UIImageView?
and add this:
func applicationDidEnterBackground(_ application: UIApplication) {
imageView = UIImageView(frame: window!.frame)
imageView?.image = UIImage(named: "AppIcon")
window?.addSubview(imageView!)
}
func applicationWillEnterForeground(_ application: UIApplication) {
if imageView != nil {
imageView?.removeFromSuperview()
imageView = nil
}
}
background with black color
func applicationDidEnterBackground(_ application: UIApplication) {
let blankViewController = UIViewController()
blankViewController.view.backgroundColor = UIColor.black
window?.rootViewController?.present(blankViewController, animated: false)
}
func applicationWillEnterForeground(_ application: UIApplication) {
window?.rootViewController?.dismiss(animated: false)
}