kciter / Floaty

:heart: Floating Action Button for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Floaty Action Button - Plus Symbol Moving out of Button

Contreux opened this issue · comments

When one taps on the action button it will bring up the actions but if you move the app into background mode without closing the action button when reentering the app the Plus symbol moves up and across into a different position.

Close the action button when navigating away

Similar to #266

Hi @willMorph
Quick fix is to call floaty.close() on following events:

  1. View will disappear
  2. When app moves to background
override func viewDidLoad() {
    super.viewDidLoad()
    let notificationCenter = NotificationCenter.default
    notificationCenter.addObserver(self, selector: #selector(appMovedToBackground), name: UIApplication.willResignActiveNotification, object: nil)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    appMovedToBackground()
}

@objc func appMovedToBackground() {
    floaty.close()
}