简体   繁体   中英

iOS 13 new pageSheet/formSheet navigationBar Height

As we can see from image below, the new presentation style of iOS 13 built with XCode 11 made navigation bar have a different height (56 height) compared to the one presented 'fullscreen' (44 height).

The problem here is my app is using a custom written navigation bar and the height of the custom navigation bar is calculated with UINavigationController.navigationBar.frame.height which give us 44 height as default. We are trying to adopt to the new presentation style, but I could not think of a work-around. I think I'm also not covered situation such as large title navigation bar and compact navigation bar. Any help would be greatly appreciated.

Credits to: https://medium.com/@hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e

在此处输入图像描述 2) Image with navigationBar Height of 56 in presentationStyle.pageSheet

在此处输入图像描述 3) Image with navigationBar Height of 44 in presentationStyle.fullScreen

This is seems to be a bug in iOS, I've used this workaround , but I call it in viewDidLoad instead of viewWillAppear because the latter applied the fix only after the view controller animation finished.

override func viewDidLoad(_ animated: Bool) {  
     // ... 
     if #available(iOS 13.0, *) {  
          navigationController?.navigationBar.setNeedsLayout()  
     }  
}  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM