[英]NavigationBar prefersLargeTitle not working
Using iOS 13.3,使用 iOS 13.3,
I observe a strange behaviour of the navigationBar.我观察到导航栏的奇怪行为。 If dragging up, the navigationBar contracts.如果向上拖动,navigationBar 会收缩。 (see video) (见视频)
Don't worry about the tabs that are part of the navigationBar.不要担心作为导航栏一部分的选项卡。 The strange behaviour also happens without them.没有它们也会发生奇怪的行为。 And also the fact that the ViewController presents in a modal sheet is irrelevant - the strange contraction behaviour also happens in a classic view.而且 ViewController 出现在模态表中的事实是无关紧要的 - 奇怪的收缩行为也发生在经典视图中。 So far, I only knew this contracting behaviour from a SearchBar.到目前为止,我只从 SearchBar 知道这种收缩行为。 But no such is present here.但这里没有这样的东西。
How can I always keep the navigationBar at a fixed large size ?如何始终将导航栏保持在固定的大尺寸?
I tried without success....我试过没有成功....
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always
I finally found the solution:我终于找到了解决方案:
Since there was a tableView in the screen, the following was needed to prevent the contracting of the navigationBar:由于屏幕中有一个tableView,因此需要以下内容来防止navigationBar的收缩:
tableView.isScrollEnabled = false
If your navigationBar has a custom height or for other reasons, you can also set the tableView's Insets to place it downwards like this:如果您的导航栏具有自定义高度或出于其他原因,您还可以设置 tableView 的 Insets 将其向下放置,如下所示:
tableView.contentInset = UIEdgeInsets(top: 90.0, left: 0.0, bottom: 0.0, right: 0.0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.