I have a UIViewController which holds a UITableView and also have a navigation bar with a large title. Whenever I scroll down through the table view, the large title disappears and becomes a small header. How can I maintain the large title (make it static/sticky) when I scroll through.
I added a picture of my screen before the swipe, in the middle of a swipe, and after the swipe.
I want to maintain the large title seen in the before the swipe image even after the swipe occurs.
The code I currently have in terms of the navigation bar (for the large header and transparency) is as follows
class OneChallengeViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
let productCellId = "TableViewCell1TableViewCell"
var products = [ProductDto]()
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = "Challenges"
navigationController?.navigationBar.barStyle = .default
navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
navigationController?.navigationItem.largeTitleDisplayMode = .always
}
The title will collapse on scroll as long as the root view is scrollable, i.e. is a scrollView or a view which embeds a UIScrollView
.
To achieve what you want in the particular case you'd need to add a dummy view ahead of your tableView
in the view hierarchy.
I've found your question while searching how to achieve the opposite 😅