I am trying to change the navigationController push and pop animation like presentModalView and dismissModalView animation.
I am successfully change the push view animation by using the below code. For changing push animation is working fine. This code is shows the view from bottom to top animation(for push view).
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:locationObj animated:NO];
But When I am trying to change the pop view animation by using the below code. I am unable to get the top to bottom animation(for pop view).
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
Please can some one help me.
Tested Code:
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//Pop Animation
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
//Push Animation
//transition.type = kCATransitionMoveIn;
//transition.subtype = kCATransitionFromTop;
//[self.navigationController.view.layer addAnimation:transition forKey:nil];
//[self.navigationController pushViewController:viewControllerToBePushed animated:NO];
Related
I need Present modal view controller animate from left to right like
drawer?
My code:-
MenuViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"MenuViewStory"];
vc.delegate= self;
CATransition *transition = [CATransition animation];
transition.duration = 0.6;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromLeft;
[vc.view.window.layer addAnimation:transition forKey:nil];
[self presentViewController:vc animated:YES completion:nil];
Hey you can use below method while pushing a controller in navigation controller with animated NO
- (void)animateControllerFromLeftToRight
{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setDuration:0.65f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.navigationController.view layer] addAnimation:animation forKey:#"AnimationFromLeftToRight"];
}
I want to transition my View Controller Right to Left (just like a Navigation Controller does IT) BUT without a UINavigationController embedded. I'm using Xcode 7 and the standard Segue seems to not have this option. Any guidance is VERY much welcome!!!
If you want to be a hack, you can do this:
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:viewCtrl animated:NO];
You should really just use a navigation controller or write a custom transition animation see here for a project that does the animation you want.
let transition = CATransition()
transition.duration = 0.3
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.view.window?.layer.addAnimation(transition,forKey:nil)
self.presentViewController(viewCtrl, animated: false, completion: nil)
if you need it in Swift.
for transition from one viewController to another view i wrote code below like this
if (UIInterfaceOrientationIsLandscape(STATUSBAR_ORIENTATION)) {
transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:nil];
}
else
{
transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:nil];
}
[self presentViewController:webView animated:NO completion:nil];
It is working fine but when i am rotate in landscape to portrait at the time onwards the view transition from right to left coming how to resolve this...please help me
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?
I am trying to get the navigation controller direction to be kCATransitionFromTop with the CATransition and it is set up to do that however for some reason it is still going from right to left. The fade portion works perfectly. Is there anything that I am doing wrong to have this not work? Do I need to add code in the other view controller? Thanks
- (void)bottomButtonScreen4:(UIGestureRecognizer *)gestureRecognizer {
settingsViewController = [[SettingsViewController alloc] init];
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:settingsViewController animated:YES];
}
The type should be push, and the subtype kCATransitionFromBottom (which actually makes it come in from the top):
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:settingsViewController animated:NO];