user8496305
user8496305

Reputation:

iOS 11 issues with navigationBar prefersLargeTitles

Xcode 9 beta 6 iOS 11

I have a storyboard for a viewController, the background ImageView, tableView and the searchFooter view are the subViews of the view.The structure is as follows:

enter image description here

In the AppDelegate class,I set
UINavigationBar.appearance().prefersLargeTitles = true

and

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

UINavigationBar.appearance().shadowImage = UIImage()

In the viewControllerclass,I set navigationItem.searchController = searchController and navigationItem.hidesSearchBarWhenScrolling = true

When I run the application, I found that the shadowImage of the navigationBar was still exist. The navigationBar wouldn't become normal(not the prefersLargeTitles mode ) automatically(the left gif) when I scrolled the tableView.I hope the navigationBar can work just like the system app(the right gif).

my appsystem app

A weird behavior: When I remove the background imageView, it can work as well as the system app on the simulator.

I don't know why it happened,I wonder how to solve it? Thanks.

Upvotes: 22

Views: 2967

Answers (4)

Make your TableView Top constraint right under NavigationController's NavigationsBar, not ViewControllers Top. It should work

Upvotes: 0

serdaryillar
serdaryillar

Reputation: 413

I've made a small application for your issue. You can reach the project on Github.

Transparent NavigationBar for iOS11

Note: You must use a color for UINavigationBar when scrolling up.

Upvotes: 2

Ringo
Ringo

Reputation: 1293

The account has been deleted by Stack overflow team. So I use my another ID to comment here. I have reported the issue to Apple,they asked me to provide a project and I did, but no more further comment from Apple.

Upvotes: 0

iSK
iSK

Reputation: 1

You should add below line in viewDidLoad()

self.navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.hidesSearchBarWhenScrolling = false

OR YOU CAN implement viewForHeaderInSection method of 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

Upvotes: -1

Related Questions