LARGE NAVIGATION
TITLE BAR FOR TABLEVIEW

Set Large Navigation Title For TableView

The tempting thing of developing apps is including native features in our application which makes people to feel the native spice . Similarly, Here I am going to implement native tableView scrolling with large and small navigation titles. You can see this scrolling feature in iPhone’s own settings screen. Here am going to add a piece of code which will makes work like above.

The Core Spell

The core logic here is to achieve this feature is

  • Implement tableView with delegates initially.

Large Navigation Title

Larger Navigation Bar titles

NAVIGATION
TITLE

Set Large Navigation Title For TableView

The tempting thing of developing apps is including native features in our application which makes people to feel the native spice . Similarly, Here I am going to implement native tableView scrolling with large and small navigation titles. You can see this scrolling feature in iPhone’s own settings screen. Here am going to add a piece of code which will makes work like above.

The Core Spell

The core logic here is to achieve this feature is

  • Implement tableView with delegates initially.

Large Navigation Title

Large Navigation Title bar

In ViewController.swift

In ViewDidLoad() add the below to set Large Navigation Title:

override func viewDidLoad() {

super.viewDidLoad()

navigationController?.navigationBar.prefersLargeTitles = true

navigationItem.largeTitleDisplayMode = .automatic

navigationController?.navigationBar.sizeToFit()

self.tableView.contentInsetAdjustmentBehavior = .never

}

In ScrollView delegate add below code:

func scrollViewDidScroll(_ scrollView: UIScrollView) {

if scrollView == tableView{

if tableView.contentOffset.y > 3.0{

self.navigationController?.navigationBar.prefersLargeTitles = false

}

if tableView.contentOffset.y == 0.0{

self.navigationController?.navigationBar.prefersLargeTitles = true

self.navigationItem.largeTitleDisplayMode = .automatic

self.navigationController?.navigationBar.sizeToFit()

}

}

}

Here is the storyboard for our implementation

On scroll becomes small title

Title becomes small on scroll

This is how Large navigation title works with tableview and becomes small on table scroll which exceeds the content offset above 2 and once become 0(content offset) get back to large navigation titles.

Happy Coding!😊

Follow Me for more rare concepts of iOS. Have any doubts and need idea in new concepts, relax and mail me to lyvennithasasikumar@gmail.com.

Passionate iOS developer chasing my dreams toward success