Is there any way to override the titleView fading in iOS 7? - ios

I'm trying to figure out how to override the iOS 7 fading animation on my UINavigationBar's titleView when transitioning to a new view, but I can't seem to get it to change. Basically, I just want to stop the fading animation and keep the titleView's alpha at 1.0, but no matter what I try it always seems to fade out then back in. I'm using a custom transition using the new UIViewControllerTransitioningDelegate, which leaves the navigation bar there while the view transitions (which is desired), but still fades. Any suggestions?
Thanks,
-Stephen

There's no way to do that. Title views aren't shared from one view controller to the next across the transition. The old title view is replaced with the new one, using a cross-fade, even if the titles have the same text. To prevent fading, you'd need to write your own navigation controller / navigation bar / navigation item classes.

Related

iOS - Customize Navigation Bar for only some UIViewController

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.

How to make titleView remain in UINavigationBar during push/pop transition like Facebook app?

Here is a transitioning animation of UINavigationBar used in Facebook for iOS:
The topViewController is being changed, but the titleView is transitioning seamlessly.
(For your information, the two textfields are the same instance (checked with FLEX). However, I don’t care if the two textfields are not the same instance.)
What's the best way of approaching this?
Thanking you in anticipation.
I'm fairly confident that is not a navigation push/pop. I suspect what they're doing is hiding the left bar button to make the search field larger, and then just adding a view on top of the current VC's view. When you cancel, they hide the view and show the bar button. The clues I'm using to draw this conclusion are that (a) I've been writing iphone apps for years and I have no idea how to make a nav controller/bar do what you want with a push/pop, at least not without a lot of faking it and hoop jumping, (b) you video has the new view "pushing" from the wrong side, and (c) in my copy of the FB app, there is a different animation where the second view just appears/disappears without any push/pop animation.

IOS Custom View or Navigation Bar Controller

I am new to IOS Swift development. I have a navigation bar design which includes, increasing the height (thus increased text size with custom colors), custom UIButton for closing (instead of the usual back button)
and title at the left side (instead of center)
Basically a lot of customization to do. My question is, is it okay to do a custom UIView to act as a navigation bar or should I push through with a NavigationController and just customize it via code?
Thank you.
First of all the navigation bar offer the push navigation through different view controllers in a smarter way, it stacking all the view controllers pushed and it offers some useful features; for example pushing another view controller from storyboard you don't have the need to set the back button and you can come back to the main controller in a simple way.
You can set a custom image for left/right button, set custom fonts and also change the height without big problems; I suggest to keep the navigation bar and evaluate, you should discover in a short time if a nav bar is enough for your needs.

How to push entire view in iOS including navigation bar and toolbar

I have 3 views connected together via a navigation controller. The middle view (#2) has special styling in that the navigation bar and toolbar are completely white to blend in with the white background.
When swiping to/from view 2 the navigation and toolbar transition is animated (as is the default) to slowly fade in the buttons and styling of the view being pushed/popped i.e. the navigation bar and toolbar remain visible during the transition.
This ends up not looking to great because of the white navigation bar and toolbar of view 2.
What I would like to achieve instead is to have each view pushed/popped in entirety i.e. including its navigation bar and toolbar. In other words, instead of the navigation bar and toolbar to persist during the transition, I would like them to slide in/out with the view they are part of.
I have attached screenshots of the 2 variants.
Would it be best to scrap the navigation controller and set up each view with its own navigation bar and toolbar? Or can this be achieved easily for my current setup.
It would be great if someone could point me in the right direction.
This is from the Apple Remote app showing the effect I would like to create.
This is from the Apple Mail app showing the default transition effect.
Use custom transitions between view controllers will give you a better effect than animating UIView's, though you can add physics behaviors to UIView objects to make it more interesting.
Apple uses interactive custom transitions (just look that up) for its own apps. Here is a good article about that too:
http://www.doubleencore.com/2013/09/ios-7-custom-transitions/
Create your view with the desired screen with navigation bar & tollbar.
On the action bring the view 2 or remove with the animation your want using view animation.
[UIView animateWithDuration:0.2
animations:^{set your fram(0,0,320,480/568) or (320,0,320,480/568)}
completion:^(BOOL finished){
}];
You can add the view to keywindow.
Hope this will help you.
Why don't you simply use the hidesBottomBarWhenPushed property over the destination view controller?
// hide the bottom tabbar when we push this view controller
destinationViewController.hidesBottomBarWhenPushed = YES;

presentViewController with custom transition

I would like to present a modal UIViewController with a different transitions to the ones available by the toolkit. Precisely I'd like an inverted animation compared to the slide from the bottom (UIModalTransitionStyleCoverVertical), present = slide in from the top, dismiss = slide out from the top.
I don't think there is a simply option for UIModalTransitionStyleCoverVertical to be inverted, so I guess I need to make one on my own.
I am also not using segue/storyboard either, not sure if this makes a difference.
I found some solutions which suggest to simply animate the new viewcontroller view and use presentViewController with the animated option as NO. Unfortunately the problem I have is that the background turns black straight away, even If I define the new viewcontroller view with clear background and not opaque.
Any idea how I could sort this out? Thanks a lot!
I solved the not transparent background issue taking a screenshot and using it as background for the modal view controller.
Apply your custom animation with CATransition.
Set modalPresentationStyle property for the presented view controller to UIModalPresentationCustom (available for iOS 7 or later). See also UIModalPresentationOverCurrentContext iOS8, or UIModalPresentationCurrentContext.
For my case I wanted to the same animation style, but I only needed to use UIModalPresentationOverCurrentContext for iOS 8.

Resources