0

I have created a parallax detail view in swift. Wish to allow nav bar colour and title display when user scrolls down.

Like this example here on the detail view. This is in objective C and I can't figure out the swift version. I'm sure it's simple enough with a few lines of code in the right place.

https://github.com/KMindeguia/movies/blob/master/README.md

I know the nav bar has a .hideswhenuserswips function but can't find anything for this!

Thanks

4 Answers4

0

If you use storyboard for your UINavigationController, you can set like this set on storyboard

Or, you can set in your code like this:

myNavigationController.hidesBarsOnSwipe = true
EricXuan
  • 387
  • 1
  • 2
  • 11
0

You can use scrollview delegate methods to show or hide navigation bar.

you can implement scrollViewDidScroll , scrollViewDidEndDecelerating or scrollViewWillBeginDecelerating.

from this delegate methods you can manage your navigation bar.

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Thanks so I can just set navigationBar.hidden = false but scrolling but how would I get the navigation bar to show only after the top uiimage is out of sight. (Like the example I linked) – Mark Pitch Jun 01 '16 at 15:54
0

This component just using simple UIView and implementing UIScrollViewDelegate methods. You can add your custom view in top of parent view and hide it, implement UIScrollViewDelegate methods and track some contentOffset of uiscrollview. Like in this component from lines 237
scrollDelegate methods

iSashok
  • 2,326
  • 13
  • 21
0

Set the NavigationBar in each viewcontroller, if you would not show navigationbar use this code,

self.navigationController?.navigationBarHidden = true

And show the navigationbar in particular viewController put this below code,

self.navigationController?.navigationBarHidden = false

this lines used your method, or you use this code,

override func viewWillAppear(animated: Bool)
{
    super.viewWillAppear(animated)
    self.navigationController?.navigationBarHidden = true
}

override func viewWillDisappear(animated: Bool)
{
    super.viewWillDisappear(animated)
    self.navigationController?.navigationBarHidden = false
}

when scrolling to show your navigationbar see this link Hide status bar while scrolling

hope its helpful

Community
  • 1
  • 1
Iyyappan Ravi
  • 3,205
  • 2
  • 16
  • 30