FloatingPanel icon indicating copy to clipboard operation
FloatingPanel copied to clipboard

UINavigationBar in FloatingPanelController include status bar height when anchor is tip/half

Open ShoMasegi opened this issue 3 years ago • 2 comments

Description

Setting UINavigationController in FloatingPanelController, and do addPanel(toParent:) when viewDidLoad, UINavigationBar height is wrong. I considered that UINavigationBar height include status bar height. This problem is occurred when floating panel anchor is tip or half, not full.

スクリーンショット 2021-05-21 3 15 32

Expected behavior

UINavigationBar do not include status bar height.

Actual behavior

UINavigationBar included status bar height.

Steps to reproduce

  1. set UINavigationController in FloatingPanelController
  2. addPanel(toParent:) when viewDidLoad
  3. wrong height navigationBar shown

Code example that reproduces the issue

class ViewController: UIViewController {
  override func viewDidLoad() {
    let fpc = FloatingPanelController()
    let nc = UINavigationController(rootViewController: UIViewController())
    fpc.set(contentViewController: nc)
    fpc.addPanel(toParent: self)
  }
}

How do you display panel(s)?

addPanel(toParent:)

How many panels do you displays? 1

Environment

Library version Latest (2.3.1)

Installation method

In any way

  • CocoaPods
  • Carthage
  • Swift Package Manager

iOS version(s) 14.5

Xcode version Version 12.5 (12E262)

ShoMasegi avatar May 20 '21 18:05 ShoMasegi

Thanks for reporting that. After my investigation, I figure out that it's out of scope of this library because UIKit doesn't provide an API to turn off the safe area and expansion of the navigation bar(UIViewController.edgesForExtendedLayout doesn't work well) :cry: But I found a workaround to escape this issue. That is adding a panel in viewDidAppear like below.

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    self.fpc.addPanel(toParent: self, animated: true)
}

scenee avatar May 22 '21 02:05 scenee

Thanks for investigation and workaround! I'll try this workaround👍

ShoMasegi avatar May 27 '21 07:05 ShoMasegi