Fully custom view with animations for UINavigationBar - ios

I want to make a drop-in replacement for UINavigationBar with custom controls and transition animations. When I say "custom", I don't mean just tweaking around the edges like changing colours/title or placing custom views inside left/right UIBarButton slots, I mean a completely custom view and animations.
However, customisation capabilities of UINavigationBar are limited, as it has its own opaque internal hierarchy of views, which is ill-advised to tamper with.
The question is, is there any way to have a replacement for the navigation bar without having to also rewrite UINavigationController?
I'm also open to alternatives where the stock navigation bar is completely hidden and a custom navigation bar animates alongside pop/push transition animations.

Related

Cons of using a UIView as a Navigation Bar

In a specific view controller I have content that I need placed in the navigation bar that exceeds the maximum height of the navigation bar. From what I understand since iOS 11 the navigation bar's height cannot be extended.
What are the cons of hiding the navigation bar in this view controller and replacing it with a UIView that looks and behaves like a navigation bar? This way I would be able to fit my custom content.
UINavigationController gives use a lot of default functionality which helps you in the navigation. But if you want to use the UIView in place of navigationBar then you have to write the whole code for each functionality.
No such consequences, when you use UIView in place of UINavigationController/Bar.
You can see what functionality apple offers you https://developer.apple.com/documentation/uikit/uinavigationbar

how can I make three paging views with a custom nav bar in swift

Final Design
I'm trying to make this, three paging views in one with a custom nav bar with icons that will scale when its view is brought up. What is the best way to make the three views, like snapchat's, and how can I relate them to the icons in the nav bar to them? I know that I'll use collection view inside those views with supplementary cells.
I tried to make a Collection View with 3 cells moving horizontally to make the views but I cant relate the icons in the nav bar.
By the way, is it possible to make the navbar triangular like in the GIF?
This is a very broad question but will try to give you pointers for each of the features you are requesting.
To handle the paging views similar to snapchat with relative icons check out SLPagingView. This is a great place for you to get started. You'll need to add in some more code for the scaling but should be trivial.
In order to create a navigation bar similar to what you want you'll need to subclass UINavigationBar and override sizeThatFits and set a backgroundImage. See here here and here.

Best approach for creating this custom UINavigationbar ios

I am creating a UINavigationBar that will expand and contract in various states. The top image is when it is in a contracted state with a transparent background. The lower image represents when it has expanded with a background and search bar. As the user scrolls down the nav bar background would animate in and expose the search field.
Can someone suggest the best way to build this?
So far I've explored subclassing the UINavigationBar, but I've been having a really tough time with the placement of the items within the nav bar or hooking that view up to a xib. I've also see examples where the extended content is just a UIview anchored to the top of the view controller top margin, but then I'm splitting the appearance of my nav into two views which will make the animation problematic.
According to the answer to UISegmentedControl below UINavigationbar in iOS 7 it can be accomplished using a UIToolBar and some delegate methods.
You might have to tweak it a little bit however, to fit the search bar that you want to include.

Creating custom implementation of navigation bar

I wish to create a view similar in behavior to the UINavigationBar.
I cannot simply customize the bar as I want the space to be taller and I want to have several other subviews on it other than just UIBarButtonItems. So, I want to be able to create a similar implementation including the floating/translucency effect.
I good example of this is the address bar in Safari in iOS 7. The UITextField on the bar is something that cannot be added on the default UINavigationBar. Nevertheless, the Safari bar still has the transparency.
I do not want it to shrink like it does in Safari when scrolling down, I simply want it to remain just like a UINavigationBar would. I was thinking about adding a subview to the root UIScrollView, but this would scroll along with everything. I want this to remain at the top, but I want other elements to be able to scroll.
How would I go about implementing this?
If you are confident that you can't to this with the default UINavigationBar, you could shrink (from the top) the UIScrollView with whatever the size the custom UINavigationBar is and then add the navbar as a subview to the root view at (0,0) coordinates. It will be independent from the scroll view.
On the other hand, if you need this to be persistent through the application and use it in all of the screens, it will be wise to make some changes starting for the AppDelegate, but that's for another question.
For the iOS 7 transparent-style part, look here: FXBlurView. Best of luck!

UINavigationController toolbar 100% transparent

In a storyboard I create a ![UINavigationController] with its root view controller a UIViewcontroller. In the toolbar I have a segmented control. I made it transparent, but only has the normal tint, I expect to see the normal background or the table view blurred under it, but its 100% transparent for some reason.
This is a known bug in iOS7, when presenting a popover from a bar button item.
First open a bug report so Apple gives this issue more priority.
As a workaround, make sure to set the edges for extended layout to none for view controllers inside popovers. For reference, you can see in Apple's calendar app they also do this. There is no translucency under popover navigation bars and toolbars.

Resources