I'm following this guide to do a custom transition between two UIViewControllers that are within a navigation controller.
I'm trying to replicate the transition this 'Storehouse' app transition ,see the transition on the far left.
Notice that the transition includes the navigation bar. However, by default the transition only applies to the view UNDER the navigation bar and just crossfades the UINavigation bars between views.
I want a reference to the entire views including the navigation bar so that I can recreate this effect. I understand I'm probably seeing this behavior since they share a UINavigationController, and thus a navigation bar.
Any ideas?
Thanks!
See here
This is a much asked question here on SO btw. Maybe use the search functionality first next time? ;)
EDIT
Reviewing the transition you posted I must say it does not look like this is a UINavigationController setup. The solution I linked above works for a default setup. It looks like 'Storehouse' has put up a custom solution here. (I looks very neat though!).You will probably have to code this by yourself, i.e. fake the navigation bar.
Related
I have to add new screens to an existing app, that will use a different navigation bar style than the one that already exists and will be accessed from different screens. The idea would be to show the new Navigation Bar style only for those screens, so when the user finishes that flow or goes back to the screen that started the navigation, it should show again the navigation bar style it was previously using.
I have tried 2 things but didn't work as expected:
I thought of wrapping the new screens in a new UINavigationController, so I could change its navigation bar style and it would be consistent for the new screens. It works but the problem is that I am not able to customize the initial UINavigationController transition to make it not look like a modal (i.e I want to show that UINavigationController with the same animation as if I were pushing a UIViewController). Is there a way to do that? By the way, I am managing the navigations with storyboards segues.
I also thought of using
self.navigationController?.navigationBar.isHidden = true
But doesn't seem clean because I would have to show it again when the flow is finished (it is a bit long) or cancelled. This makes a lot of combinations and it would be easy to miss one of them, so this doesn't seem a practical solution. Is there a better way to do this?
The presenting view controller is where you want to change the nav bar for the controller to be presented. So you'd make any changes to the navbar just before you call push(viewController:animated:).
And then in viewWillAppear of still the presenting view controller you would reset the navbar to what it was initially.
NOTE: Keep in mind that depending on the kind of changes you're doing to the navbar, the transition might no longer be smooth. The user might see some flickering of sorts on the navbar, which would be poor UI/UX.
Edit: Another alternative
Alternatively, you could get rid of the navbar and instead implement your own header view that you can style however you want, to represent the navbar.
You can style it as a simple navbar with a title + back button.
You can style it to look like a navbar with large title
You can style it as a navbar with back button + background image + title + right bar buttons
As you can see, this second alternative offers you more freedom in what you can do.
I have a simple Navigation View Hierarchy that has 2 views it goes between. I wanted a customized navigation bar, so I have the default one hidden, and I've implemented a Container View which is shared between the 2 views in the nav hierarchy.
Everything works as I want it to, except when I segue to the lower or higher view the top bar appears slides away and reappears on the new view. I would like it to appear stationary when I push or pop to other views in the hierarchy.
Is there an easy way to do this? Or should I delete my custom shared Container View and try to make this work with the Navigation Bar (which I have currently "hidden")?
I had to do this for a client once. The way we did it was, like you said, make an encompassing view controller that housed a container view. Within this container view, we embedded a UINavigationController and would manually pop and push UIViewControllers to its navigation stack. Of course you want to hide the UINavigationController's nav bar.
It sounds like you sort of implemented this, but instead you just embedded a plain old view controller inside your custom navigation controller, and then segue to another view controller that is also embedded in the custom view controller? Ideally you want one instance of this custom nav controller with an embedded UINavigationController. I believe you will have to do all the view controller transitions programmatically.
Opinion: Personally, I would recommend against doing this. I believe that an app should feel like an extension of the OS it's on. A user should feel it's a part of their phone. Using the native navigation bar also decreases the level of effort a user is required to put forth to understand your app.
I know you're thinking "but it's just a nav bar" but we're talking about the same people that will potentially uninstall an app if it takes longer than 2.5s to load.
I wanted a customized navigation bar, so I have the default one hidden
That's your mistake. The way to get a customized navigation bar in a UINavigationController interface is to initialize it with init(navigationBarClass:toolbarClass:). Now the built-in navigation controller is using your navigation bar! And from there on, all will be well.
https://developer.apple.com/reference/uikit/uinavigationcontroller/1621866-init
After finally getting my UITabBarConntroller to work, I have read in the apple docs, that I should not use a UITabBarController as a child of my Navigation Controller.
My app, segues from a TVC to my TabBar, which has a few tabs.
For example
I want to modal segue from each coloured view.
I am wondering if the red view should be the delegate for each of the views, or should they all be independent.
What you are trying to do here is basically to implement your own Tabbarcontroller. Apple does not recommend to put a Tabbarcontroller as a child of a Navigationcontroller due to usability reasons. Technically, you can do this but it is not really good as users of iOS are used to have a TabbarController as the root view of each navigation stack and therefore an approach like yours might make your app confusing and hard to understand.
Nevertheless, if you insist to stick to your idea, you can just simply put a tab bar controller into a navigation controller in your storyboard which should do its work. Still, I would recommend to rethink your app's navigation structure. Take a look at other popular Apple apps and Apple's Tabbar Controller Documentation as inspiration.
Im sorry if the Title of question isn't 100% correct. To be honest Im not sure how to describe my question. I have problem. I have app which has Navigation Controller (title is called List). In navigation controller I have "Add" item. When I touch the Item, new View Controller is called. When I touch Back button, which is called "List". When I do slide gesture to go back, Button < called "Title" disappear and again appear even if name is same - "Title". I made gif animation to be clear. Does anybody know how to make my app just slide the title without any (dis)appear? Thank you very much and sorry If my english is not best:)
This is the standard UINavigationController behavior and I don't believe you can easily change this. Two options come to mind:
If you really want this feature, the simplest solution is to tell your navigation controller to not show the navigation bar:
Then you can add your own navigation bar to your scenes. You'll have to manually add back buttons that you hook up to IBAction that pops the view controller (or an unwind segue to the previous scene). If your app supports landscape mode, you may also want to tweak the rotation behavior so it's shorter in landscape mode than portrait mode (like the navigation controller does).
By doing this, you still enjoy the navigation controller functionality (pushing and popping), though you're manually adding navigation bars to every scene. The UX isn't going to be identical and you lose interactive pop gesture, too, but it's probably the easiest was to achieve your desired transition animation.
If that's not adequate (e.g. you need interactive gesture for popping, etc.), then you can write this yourself, retiring the navigation controller entirely and then use custom interactive transitions. This was introduced in iOS 7 (see WWDC 2013 video Custom Transitions Using View Controllers) and revised in iOS 8 (see WWDC 2014 video View Controller Advancements in iOS 8).
Frankly, these both feel like heavy-handed solutions (especially the second one), but if you really want to change the animation of the navigation bar associated with the navigation controller, then these are two options. Personally, I'd step back and do a cost-benefit analysis of this endeavor and decide whether this is worth it for a fairly minor UI issue.
I am well aware of how to implement my own drawing of a navigation bar. What I want to active is something similar to the Jetsetter iPhone application. Which has a very nice animation when swapping between view controllers (in a similar way you would push/pop view controllers in a UINavigationController stack).
Would this require a complete rewrite of the UINavigationController or could I somehow just override some vital parts?
I would be great full for any information right now.
Thanks
In my opinion, they hide the navigation bar and roll their own view.
Please check this link.
On some views they are not using a navigation bar, they are just creating a simple view and adding buttons for popping and pushing, but on some views, they change the navigation bar background and initialize the backbarbutton and forward button items and title with their own views and then add gestures recognizers to these, its very simple.