We have an Offline Data Synchronization in our application. When we have any pending transactions [i.e. transactions made offline], if the device is online, we sync those activities to the server. while syncing, we display a banner view with syncing status at the top of the screen; for this, we are updating the additional safe area insets; once syncing is complete, we refresh the additional safe area insets.

But we have noticed strange issues such as white space at the top of the navigation bar and incorrect navigation alignment. I have attached screenshots for your reference.

Bug screenshot

Code Snippet

  private func updateTopSafeAreaInset(withStatus isStatusViewShown: Bool) {
    var newSafeArea = UIEdgeInsets()
    if isStatusViewShown {
      newSafeArea.top += 20
    }
    let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
    UIView.animate(withDuration: 0.2, delay: 0, options: .curveLinear) {
      // to update safe area top inset when reachability status view is presented or dismissed
      window?.rootViewController?.additionalSafeAreaInsets = newSafeArea
      window?.rootViewController?.presentedViewController?.additionalSafeAreaInsets = newSafeArea
    }
  }

Expectation

The navigation bar should not have any white space at the top, and it should be properly aligned.

Any help would be greatly appreciated! Thanks!

0

There are 0 best solutions below