iOS11如何通过滚动同步大型导航栏崩溃

Dav*_*eek 6 swift ios11

使用Swift 3和Xcode 9我正在使用大UINavigationBar视图:

if #available(iOS 11.0, *) {

    navigationBar?.prefersLargeTitles = true

    UINavigationBar.appearance().largeTitleTextAttributes = [
        NSForegroundColorAttributeName: Colors.black
    ]

}
Run Code Online (Sandbox Code Playgroud)

当我滚动a时UITableView,条形图会快速折叠,从而产生不需要的空间:

之前:

在此输入图像描述

后:

在此输入图像描述

我碰到UITableView酒吧的那一刻就崩溃了.

tableView具有以下属性:

let rect = CGRect(

    x: 0,
    y: UIApplication.shared.statusBarView?.frame.height ?? 20,
    width: UIScreen.main.bounds.width,
    height: UIScreen.main.bounds.height

)

let tableView = UITableView(frame: rect)
Run Code Online (Sandbox Code Playgroud)

最顶层的tableViewself.navigationController?.navigationBar.frame.height ?? 44

另外,tableView设置为:

if #available(iOS 11.0, *) {
    self.contentInsetAdjustmentBehavior = .never
} 
Run Code Online (Sandbox Code Playgroud)

酒吧是半透明的,我希望保持这一点.我错过了什么?非常感谢帮助.

Dav*_*eek 0

我使用以下方法让它工作:

if #available(iOS 11.0, *) {
    self.contentInsetAdjustmentBehavior = .always
} 
Run Code Online (Sandbox Code Playgroud)

let tableViewFrame = CGRect(
    x: 0,
    y: UIApplication.shared.statusBarFrame.height ?? 20,
    width: UIScreen.main.bounds.width,
    height: UIScreen.main.bounds.height
)
Run Code Online (Sandbox Code Playgroud)

并且没有进一步的 TableView 顶部插图。