Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent navigationBar with largeTitles from collapsing when user scrolls swift4/xcode9/ios11

I want to prevent the new largeTitles navigationBar from collapsing into a standard small navigationBar when the user scrolls content. i.e. always keep the navigationBar large size with title in large font.

The reason I want to do this is that I have a segmentedControl in the navigationBar above the title exactly like in the iOS phone missed calls page. Except that I always want the title and segmented control to appear. I don't want the title to disappear when the user scrolls.

Is there any default behavior that can keep the new large navigationBar from collapsing when the user scrolls?

like image 798
alionthego Avatar asked Oct 18 '25 10:10

alionthego


1 Answers

Maybe a little late but it might be useful to somebody:

If you add a scrollView (tableView, collectionView) directly to your viewControllers view, the large title will expand and collapse.

If you add any other non-scrolling view before adding the scrollView, the largeTitle will stay expanded.

i ended up doing something like

let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false

self.view.addSubview(view)
view.pinToEdgesOfSuperview()

self.view.addSubview(self.tableView)
self.tableView.pinToEdgesOfSuperview()

Not the most beautiful solution but it will work.

like image 165
qRis Avatar answered Oct 22 '25 06:10

qRis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!