Awful looking custom transition - ios

I have a problem with custom transition between controllers. I have two view controllers. First is a table view controller and initiate controller is the second one. It has a button on it's top left corner which, when it is pressed, first navigation controller is called. There should be slide animation, but from left to right, not from right to left. I made my own transition but when the button is pressed, transition looks very awful. Transition code:
CATransition *transition = [CATransition animation];
transition.duration = 0.45;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.type = kCATransitionFromLeft;
[transition setType:kCATransitionPush];
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:controller animated:NO];
This is a screenshot, how the transition looks like:

Related

Make push animate like present

I am trying to push a viewController and I want to change the animation of the push. The original puch animation is flip from right/left, I need to make it from bottom, just like the animation of present.
I tried the following code, it works, but the background will be black when the viewcontroller is animating. What can I do with it?
CATransition *animation = [CATransition animation];
animation.duration = 2.0f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fillMode = kCAFillModeForwards;
animation.type = kCATransitionPush;
animation.subtype = kCATransitionFromTop;
[[self.navigationController.view layer] addAnimation:animation forKey:#"animation"];
[self.navigationController pushViewController:controller animated:NO];
Hey you can use below method while pushing a controller in navigation controller with animated NO
- (void)animateControllerFromBottomToTop
{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setDuration:0.65f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.navigationController.view layer] addAnimation:animation forKey:#"AnimationFromBottomToTop"];
}
You can use PRESENT and still have the Navigation Bar.
Let's say your base viewController is VC1 and the next view controller which you need to push is VC2.
Just embed the VC2 inside another Navigation Controller, then create a Present Segue from VC1 to the Navigation Controller heaving VC2 as its Root.
It will be presented with your required animation and will still have the navigation bar.
Hope it helps.

UINavigationBar fades when pushing/popping

I am using the old (pre-iOS7) push/pop animation by using the method described here:
#implementation UINavigationController (Retro)
- (void)pushViewControllerRetro:(UIViewController *)viewController {
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:transition forKey:nil];
[self pushViewController:viewController animated:NO];
}
- (void)popViewControllerRetro {
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
}
#end
My problem is that iOS7 seems to fade the UINavigationBar of the previous view controller when pushing a new view controller. Normally this looks fine because iOS 7 is dragging the views on top of each other. But when I am using the pre-iOS7 animation it gives me a short flash, because the navigation bar fades while the new view it getting pushed in from the right side.
Is there a way to disable the fade animation on the navigation bar?

how to implement popover controller in storyboard, custom segue

This is mouli, I'm implementing a custom segue for pushing (with animation) from firstview to second view, its work fine. but iam not getting back from secondview to firstview with same animation. Here the first screen appears with out animation. please give some suggestion. Thanks in advance. following is my code for push from first to second.
UIViewController *sourceViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
NSLog(#"%#",sourceViewController);
sourceViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
NSLog(#"%#",destinationController);
CATransition* transition = [CATransition animation];
transition.duration = 0.6;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[destinationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil];
Do the dismiss in opposite way, since your are doing a custom animation other that the provided one, it doesn't remember the animation of presentation. So while you are dismissing you need to apply the opposite custom animation too.
I would suggest you to create a Category for animations and use them in the whole project easily..

Add Slide In from Left to Right animation(transition) in addSubView

I Try to imitate the NavigationViewController, very similar to default MailApp in iPhone
When clicking on a Mail summary, it should slide-in the mail details, and when BACK button is clicked, Mail Summary view is to be slided-in back again.
This is what I have to animate the transition from Summary To Detail (removeFromSuperView)
CGRect temp = self.view.frame;
temp.origin.x = 300;
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{
self.view.frame = temp;
}completion:^(BOOL finished){
[self.view removeFromSuperview];
}];
This is what I have to animate the transition from Detail To Summary (addSubview)
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionFromRight;
transition.subtype = kCATransitionFade;
[parentView.layer addAnimation:transition forKey:nil];
[parentView addSubview:myVC.view];
Now, that My First part of code is working well! Where-as the second part, I am just able to achieve the Fade-in animation. How can I bring in the slide transition?
I just need to choose kCATransitionPush type for my CATransition
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[parentView.layer addAnimation:transition forKey:nil];
[parentView addSubview:myVC.view];
Update for Swift:
let transition = CATransition()
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
parentView.layer.add(transition, forKey: nil)
parentView.addSubview(myVC.view)
Or you could check out : HorizontalSlide Segue (just google it I cant get the link, on mobile) its a great sliding transition that is simply a segue that you add from view A to B....
On a side note, if this is in a nav controller, a push or a pop should have a slide animation by default...

Multiple fades in a CATTransition

I'm using a CATransition to create a fade effect on the pushViewControllerAnimated of a UINavigationViewController. This worked out fine with the following code:
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromTop;
[navController.view.layer addAnimation:transition forKey:kCATransition];
[navController popViewControllerAnimated:NO];
[navController pushViewController:nieuweDetailPagina animated:NO];
But because my views are very similar I would like to fade to white in between or show a white flash.
Is it posible to do it in the same transition or do I have to creat a UIView with a white background and start a simultanious animation?
Cheers!

Resources