I'm trying to make same affect, as instagram has in their header. How can I do this?
I tried a lot of solutions.
Best - https://github.com/andreamazz/AMScrollingNavbar
But it has one big problem - it's moving bar using uipangesturerecognizer. It's bad for me, because I want to show bar, if table is at the top.
I tried to change work of this control to scroll view delegate, but found a lot of problems with it, have you any ideas, how they made this?
Use AMScrollingNavbar with your tableViewController and override the
willDisplayCell
method to show the bar if table is scrolled to top:Using that library, add this to your view controller:
I found THE solution, just like you said - you have to mess around with the scroll view delegate a little bit, but after some 2 hours I had it all figured out. The problem i was trying to solve was to be able to get the header out in one continuous motion just like you do in Instagram.
So, first check out the xib setup, it has a header view at (0 20, 320 85), which is right behind a table view at (0 20, 320 548)
So here is what it looks like after launch (table view frame in yellow):
This is what i want it to look like after pulling down (header frame in red):
So I'll just paste the code with comments, i hope its understandable enough.
Make a define
Create two properties
Than add the following implementation for
scrollViewDidScroll
delegate methodAnd enjoy your smooth table scrolling back and forth on the screen =) This can also be modified, you can add and resize a header so that it is basically identical to the Instagram one.
You can use the below mentioned method in your class in which you want to add effect on navigation bar as there in Instagram.
}