How to present different navigation title when large title collapse?
You can observe
the bounds
of the navigationBar
and change the title
using a check on the height
of the navigationBar
.
1. for Small Title, height
of navigationBar
= 44
2. for Large Title, height
of navigationBar
> 44
class VC: UIViewController {
var observer: NSKeyValueObservation?
override func viewDidLoad() {
super.viewDidLoad()
self.observer = self.navigationController?.navigationBar.observe(\.bounds, options: [.new], changeHandler: { (navigationBar, changes) in
if let height = changes.newValue?.height {
if height > 44.0 {
//Large Title
self.title = "Large Title"
} else {
//Small Title
self.title = "Small Title"
}
}
})
}
}
NavigationBar large title not collapse when I have custom image/view under tableView iOS 13
So, after a long search and a lot of tries, finally I figure out in a different way:
tblSettings.backgroundView = UIImageView(image: UIImage(named: "yourImageName"))
Setting backgroundView
to UITableView
it will allow navigation bar to animate properly to large and normal titles.
Hope this will someone!
Large title doesn't appear large
After some messing around this seems like a glitch in Xcode (for me at least)
I've managed to fix it by adding
self.navigationController?.navigationBar.prefersLargeTitles = true
in
override func viewWillAppear(_ animated: Bool)
Hope this might be useful for other people in the future
Related Topics
Reading an Inputstream into a Data Object
Uitableview - Multiple Selection and Single Selection
Avspeechutterance - Swift - Initializing with a Phrase
How to List Swift Types That Conform to Protocol Using Reflection
Translucent Status Bar with No Navigation Bar
Find Item of Specific Type in Array
App Crash on Sign in (Xcode 9.3) Exc_Bad_Access (Code=1, Address=0X1)
Wait Until an Asynchronous API Call Is Completed - Swift/Ios
Need to Check That Braces in Given Array Are Balanced or Not
How to Change Colour of the Certain Words in Label - Swift 3
How Is a Return Value of Anyobject! Different from Anyobject
Swift Lazy Subscript Ignores Filter
Swift 4 Codable - API Provides Sometimes an Int Sometimes a String
Can't Parse JSON Array with JSONdecoder in Swift 4
How to Set Countdowntimer Mode in Datepicker on Swiftui
How to Make Protocol Associated Type Require Protocol Inheritance and Not Protocol Adoption