Jose Tovar
Jose Tovar

Reputation: 189

Changing NavigationItem title size

I put the title in a nevegationItem:

let navigationItem = UINavigationItem()
navigationItem.title = "Title"
navigationBar.items = [navigationItem]

this works perfect... but.

How do I change the size of the text of Title..?

Upvotes: 1

Views: 4344

Answers (3)

Pengguna
Pengguna

Reputation: 4941

Swift 4.2

Change Large Title

self.navigationController!.navigationBar.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 22)]

Change Small Title when layout scrolled down

self.navigationController!.navigationBar.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 14)]

Upvotes: 2

Milander
Milander

Reputation: 1061

Changing the title font by using the font attributes

self.navigationController.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]

found: How do i change navigationBar font in Swift?

Upvotes: 0

Ashley Mills
Ashley Mills

Reputation: 53082

You set the font in the navigation bar…

let font = UIFont(name: "Helvetica", size: 22)!
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font]

Upvotes: 2

Related Questions