Код: Выделить всё
@IBOutlet weak var mapViewSnapShot: UIView!
NotificationCenter.default.addObserver(self, selector: #selector(MapViewController.appDidEnterBackground), name: NSNotification.Name(rawValue: "SetSnapShot"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(MapViewController.appWillEnterForeground), name: NSNotification.Name(rawValue: "RemoveSnapShot"), object: nil)
override func viewDidLoad() {
super.viewDidLoad()
mapViewSnapShot.frame = CGRect(x: 0, y: 0, width: self.view.frame.width , height: self.view.frame.height)
}
@objc func appDidEnterBackground() {
setForegroundLoader()
}
@objc func appWillEnterForeground() {
setMapCamera()
}
@objc func setForegroundLoader() {
mapViewSnapShot = mapView.snapshotView(afterScreenUpdates: true)
self.view.addSubview(mapViewSnapShot)
self.view.bringSubviewToFront(mapViewSnapShot)
}
@objc func setMapCamera() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak self] in
guard let self = self else { return }
if self.mapViewSnapShot.isDescendant(of: self.view) {
self.mapViewSnapShot.removeFromSuperview()
}
locationManager.startUpdatingLocation()
}

Подробнее здесь: https://stackoverflow.com/questions/786 ... es-from-ba