导航栏的iOS 11问题更喜欢大标题

时间:2017-09-01 04:50:14

标签: ios swift uinavigationbar uisearchcontroller ios11

Xcode 9 beta 6 iOS 11

我有viewController的故事板,背景ImageView tableView searchFooter视图是子视图view。结构如下:

enter image description here

AppDelegate课程中,我设置了
UINavigationBar.appearance().prefersLargeTitles = true

UINavigationBar.appearance().setBackgroundImage(UIImage(),for: .default)

UINavigationBar.appearance().shadowImage = UIImage()

viewController课程中,我设置了navigationItem.searchController = searchControllernavigationItem.hidesSearchBarWhenScrolling = true

  

当我运行应用程序时,我发现了shadowImage   navigationBar仍然存在。   navigationBar不会正常(不是prefersLargeTitles   模式)当我滚动tableView时自动(左边的gif)。我希望navigationBar可以像系统一样工作   app(右边的gif)。

my app system app

  

一种奇怪的行为:当我删除背景imageView时,它可以正常工作   模拟器上的系统应用程序。

我不知道为什么会这样,我想知道如何解决它?感谢。

4 个答案:

答案 0 :(得分:2)

我为你的问题做了一个小应用程序。您可以在Github上访问该项目。

Transparent NavigationBar for iOS11

注意:向上滚动时,必须使用UINavigationBar的颜色。

答案 1 :(得分:0)

Stack overflow小组已删除该帐户。所以我在这里用另一个ID来评论。 我向Apple报告了这个问题,他们让我提供了一个项目,但是我做了,但Apple没有再发表任何评论了。

答案 2 :(得分:0)

在NavigationController的NavigationsBar下创建TableView Top约束,而不是ViewControllers Top。它应该工作

答案 3 :(得分:-1)

您应该在viewDidLoad()

中添加以下行
self.navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.hidesSearchBarWhenScrolling = false

或者您可以实施viewForHeaderInSection

UITableViewDataSource方法
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? 
    {
            let search = UISearchController(searchResultsController: nil)
            search.searchResultsUpdater = self
            return search.searchBar
    }

Link to see the screenshot 1 Link to see the screenshot 2