Multiple Navigation Bar - ios

I need to put 2 NavigationBars. The second will be below the first one.
My idea is:
In the first navigation bar have the navigation buttons and in the second have only a label centered.
The rest is a UITableView controller. When the users scroll, the content hide below the navigation bars.

Paulw11 was right, you probably should create custom view, add a couple of buttons to it and attach it to the bottom of navigation bar using AutoLayout. If you need to hide this view when user scrolls, you can implement func scrollViewDidScroll(scrollView: UIScrollView) method in your UITableViewController and change it's alpha to zero.

Related

how to collapse navigationBar with large title at custom scroll offset rather than at the top of a UITableView?

I've got a tableView which is inside a view controller which is embedded in a navigation controller.
I want to customize the way the large title navigation bar shrinks to a small navigation bar. Normally, when you scroll to the top of a tableView, the small title expands to a large title.
However, I need the large title to be always visible until you scroll past a certain cell.
In the example gif, you see that the navigation bar shrinks / expands according to the position of the orange cell. You can see that there are many other blue cells on top of the orange cell, where the large title is always visible.
What I tried so far:
According to this answer, I tried adding a helper view, which prevents the navigation bar from collapsing. This worked, but now I need to figure out how to make this dynamic, so the large title would animate after a certain scroll position.
I tried using UIScrollViewDelegate:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y >= 500 {
self.view.insertSubview(helperView, aboveSubview: tableView)
} else {
self.view.insertSubview(helperView, belowSubview: tableView)
}
}
But this did not work, the navigation bar did not collapse dynamically. Just after you went to another app and switched back tho my app, the navigation bar changed its size.
Do you know of a better way to make the large title collapse / expand according to a certain scroll point and not the top of a table view?
Maybe some way of subclassing the navigationBar?

Is there a way to place a view on top of a tableview?

Right now I'm attempting to "extend the navigation bar" by placing a view under the navigation bar with the same color.
The only problem is that I'm using a tableview underneath. And tableviews extend all the way to the top.
I was wondering if there was a way to move the tableview down, so that I could place a view between the navigationbar and the start of the tableview.
Thanks!
You need to constraint the top of the table to the bottom of the view or set top inset to the table

How to hide navigation bar on scroll except when at the top of the screen

I have a UIViewController that contains a UICollectionView pinned to all edges of the view. This view controller is inside a UINavigationController.
I want to gradually hide the navigation bar as I scroll down in the collection view. At the point that I have scrolled the distance of the height of the nav bar, the nav bar should be completely hidden. If I scroll back up it should gradually show the nav bar.
I have tried all the open source navigation bars on github, but none of them work correctly with iOS 12.
How can I achieve this?
UICollectionView is a subclass of UIScrollView and therefore you have access to its scrollViewDidScroll delegate method. Your UIViewController is also owned by its navigation controller, so you can create an instance property in the view controller, like navigationDelegate: UINavigationController?, that will act as a delegate. In the navigation controller, set that property equal to self and manipulate the nav bar however you want through the scroll delegate. Absolutely no need for third-party scripting for something this standard and basic.

Add a UIImageView to the back of NavigationBar (NOT background image)

I am trying to add a UIImageView to the back of a navigation bar.
The reason is because I want to create a UITableView whose navigation bar is actually a picture (with back button on the left) but I want the picture to scroll with the tableview and when the picture is fully scrolled out. The navigation bar is shown as per normal.
My solution to this problem:
Add a UIImageView to the top of the UITableView and make the navigation bar transparent. Set a contentOffset for the UITableView which is a subclass of UIScrollView so that when the view is presented, it looks like the picture is filling the navigation status bar.
Problem:
If I scroll up, instead of bouncing back, the transparent status bar is shown (with a color of the background as it is transparent).
Possible way to solve this new problem:
I was thinking of trying to limit the ScrollView size to get around with problem but failed.
So I feel is it possible to add the UIImageView to the "back" of the navigation bar so that it is there without any offset? Since that way, my life will be much easier.
Any suggestions on solving this or another new approach to get the same UI/effect?
Related question.
I would do this by adding either a table header or cell at the top of the table which contains your image.
Create the table view so that it extends all the way to the top of the screen. Extend Under Top Bars option. I have not done this with a UITableViewController but I have done this with a UITableView embedded inside a UIViewController's view with the top constraint set to 0 for the view rather than the top layout guide.
Now when you run this your table will fill the whole screen and the top header or cell will be at the top showing your picture.
When you scroll you can either use the UIScrollViewDelegate to detect the movement or implement tableView:didEndDisplayingCell:forRowAtIndexPath:
I'm not 100% sure when you want the navigation bar to go non clear. If its when the image goes off screen then didEndDisplayingCell should be good. If its when the cell bottom passed under the bottom of the navigation bar then scroll view might be your only option.
This will also bounce as you expect when you pull down and it should snap back to the top.
Hope this helps.

UITableViewController Inside UINavigationController and UITabBarController Bottom Inset Off

I have a UITableView inside a UINavigationController that's inside a UITabBarController. There is a view on the bottom (I'll call it bottomView) between the table view and the tab bar that needs to stay at the bottom as the table view scrolls, so I can't put it as a footer in the table view.
The issue is that when i scroll to the bottom of the table view, there is an empty space the same height as the tab bar between the lowest content (and the scroll bar) and the top of bottomView.
I think this is because the table view is trying to automatically compensate for the tab view at the bottom, but I can't position it all the way at the bottom because of bottomView.
here's my IB layout:
and the display (last tableViewCell highlighted):
If I understand your question correct you need to set a contentInset to your tableView like this:
[self.tableView setContentInset:UIEdgeInsetsMake(0,0,44,0)];
Edit:
Ok I think I got it. Set:
self.automaticallyAdjustsScrollViewInsets=NO;
I've seen this same nav controller->tab bar->tableview situation frustratingly cause the tableview to partially overlap with the navigation bar, instead of not reaching the tab bar. To anyone having this issue when using a UITableView: ensure your navigation bar is not translucent. If you want to use this setup with a translucent navigation bar, select the UITabBarController in the Interface Builder and uncheck the "extend edges under top bars" option in the attributes inspector.

Resources