iOS 11 prefersLargeTitles not updating until scroll

前端 未结 24 2383
轻奢々
轻奢々 2021-01-31 07:25

I implemented a basic UIViewController with a UITableView that\'s wrapped in a UINavigationController. I set prefersLargeTitles to true:

override fu         


        
24条回答
  •  心在旅途
    2021-01-31 08:16

    Programmatically:

    1. In AppDelegate.swift:
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.makeKeyAndVisible()
    
            let navigationController = UINavigationController.init(rootViewController: ViewController())
            window?.rootViewController = navigationController
    
    1. In ViewController:
        override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
    
            navigationController?.navigationBar.prefersLargeTitles = true
            navigationItem.largeTitleDisplayMode = .automatic
        }
    
       override func loadView() {
            super.loadView()
    
            view.addSubview(tableView)
            view.addSubview(loadingView)
    
            NSLayoutConstraint.activate([
                tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
                tableView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
                tableView.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor),
                tableView.heightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.heightAnchor)
                ])
        }
    

    Make sure your tableView has beed previously added to your view.

提交回复
热议问题