         timer = nil
     }
     
+    /**
+     Stop animation when app send to background.
+     */
+    @objc private func appWillResignActive() {
+        stopAnimating()
+    }
+    
+    /**
+     Start animation when app become active.
+     */
+    @objc func appDidBecomeActive() {
+        startAnimating()
+    }
+    
+    /**
+     Add observers to the notification center to control app status
+     */
+    fileprivate func addObservers() {
+        #if !os(OSX)
+            NotificationCenter.default.addObserver(self, selector: #selector(appWillResignActive), name: Notification.Name.UIApplicationWillResignActive, object: nil)
+            NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: Notification.Name.UIApplicationDidBecomeActive, object: nil)
+        #endif
+    }
+    
     func tick() {
         guard let image = image else {
             return

        isAnimating = false
        autoStartAnimation = false
        super.init(frame: frame)
    }
    
    /**

            // fix issue that `APNGImageView` may cause crash when deinit
            layer?.contents = nil
            wantsLayer = false
        #else
            NotificationCenter.default.removeObserver(self, name:  Notification.Name.UIApplicationWillResignActive, object: nil)
            NotificationCenter.default.removeObserver(self, name:  Notification.Name.UIApplicationDidBecomeActive, object: nil)
        #endif
    }

