I want the programmatically navigate to a ViewController with this kind of transitioning that I got from stackoverflow.
CATransition* transition = [CATransition animation];
transition.duration = .45;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AddDeviceViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"AddDeviceViewController"];
self.navigationController pushViewController:vc animated:NO];
But when it transitions to the View, the navigation bar from the previous view stays. How can I make the Navigation Bar of the transitioned View appear instead of the previous one?
Implement viewWillAppear
and viewWillDisappear
in your AddDeviceViewController
. In viewWillAppear
hide navigation bar
and in viewWillDisappear
show navigation bar
. This mechanism only hide navigation bar for AddDeviceViewController
. Something like,
-(void)viewWillAppear:(BOOL)animated{
self.navigationController.navigationBar.hidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
self.navigationController.navigationBar.hidden = NO;
}