presentViewController with custom transition - ios

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.

Related

IQKeyboardManager issue , UIViewController top overlapping status bar

I am using IQKeyboardManager.
I am showing an UITextView in middle of the screen with transparent background when I click 'reply'. The entire viewController moving up, fine. but when I dismissed, the viewController top is under the statusBar.
why is it happening?
That is the behavior of IQKeyboardManager. IQKeyboardManager will take topmost view controller and based on the textView position it will push the whole view controller to up. There is nothing wrong with the library. That is how it's got implemented. So there are few ways to avoid this.
One way to use below line. Try once. I'm not sure this will work for every project.
self.view.window.windowLevel = UIWindowLevelStatusBar;
Another way is to add one more super view for TextView and try. These are few possible ways of handling it.
Try moving those TextFields inside a ScrollView and Navigation Bar (if using custom) out of ScrollView. It will solve this issue.

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.

How to make UIPageViewController transition behaviour like the interactive pop transition style in IOS7

In IOS7, when we pan on the screen edge to right, it will return the previous view controller. Also the transition is interactive, i.e., when we stop panning right, or panning distance is too short, the transition will not finished.
After reading others' blog, I know it can be called interactive pop transition.
The UIPageViewController contains many content ViewControllers, when swiping/panning the screen, we can view the different view controller, but the transition is too simple for me.
And following is my question:
I want to make the transition style in UIPageViewController like the mentioned above (interactive pop transition). They are difference in many ways, for example the previous view controller should be little darker.
And I do not want to custom my own transition style in this way, I just want to use the interactive pop transition in IOS7 default offered.
So maybe I should take some binding work? or assign some transition action in some where?
You should search for the style of interactive pop transition, and follow this custom your own transition.

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

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.

Why shouldn't I modify the UINavigationController's toolbar?

The documentation for the toolbar property in UINavigationController says:
This property contains a reference to the built-in toolbar managed by the navigation controller. Access to this toolbar is provided solely for clients that want to present an action sheet from the toolbar. You should not modify the UIToolbar object directly.
I can understand why I shouldn't modify the toolbar's visibility or items, because UINavigationController provides an interface to do that. But I've added a button that, when tapped, causes the toolbar to animate offscreen. Why shouldn't I do this?
Must I instead create my own ToolbarNavigationController class that replicates everything UINavigationController does with the toolbar just sod, I can do what I want with the toolbar? Seems like a waste of effort when the UINavigationController already does what I want. Why on earth would the docs suggest I so severely limit what I do with it?
Three ways that having moved the navigation bar might confuse it:
If your app can be rotated, does it stay in the right place after rotation? When it returns to the screen, does it animate on from the right place?
If you display a search bar, the navigation bar animates itself off. If it's already been moved manually, does it know where it is?
If you push a viewController with hidesBottomBarWhenPushed set to YES, and return, does the navigationController put its toolbar back where it belongs?
On the other hand, how about calling UINavigationController setNavigationBarHidden:NO animated:YES - does that do what you want, while letting the navigation controller maintain control of its toolbar?
Edit: Sorry about misreading. Yes, you probably can do what you're asking, as long as you don't also do anything (like item 3 above) that mean the navigationController moves its toolbar around.
On the other hand, the behavior you want can also be achieved as follows:
For the viewController with the multiple toolbars, set its hidesBottomBarWhenPushed to YES.
Place all the toolbars that viewController needs on it, and have it take full control of their positions and visibility.
If the default toolbar has the same layout as the navigationController's own toolbar, this will create the odd visual effect of seeing the same set of toolbar items slide off and then on again, but everything else should work.
UIToolbar is inaccessible because it doesn't need to be accessible. It responds to +appearance just fine. In your case, you can access the properties of a readonly variable (look at CGRect!). If you need to animate a UIToolbar or UINavigatiomBar offscreen, set it's frame.center property equal to a CGPointMake in a UIView animation block.

Resources