I am pushing a view controller whilst animating it so it flips. However, the animation is only applied to the view beneath the navigation bar, so the navigation bar hides for a few seconds then suddenly appears again. How can I apply the animation to the entire view, including the navigation bar?
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"OverviewiPad" bundle:nil];
OverviewViewController *overviewVC = [sb instantiateViewControllerWithIdentifier:#"OverviewViewController"];
overviewVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:overviewVC animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Related
I'm using a custom flip transition during a push transition.
I use this code and the flip is good:
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MyViewController* myViewController = [sb instantiateViewControllerWithIdentifier:
#"MyViewController"];
[UIView transitionWithView:self.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[self.navigationController pushViewController:myViewController animated:NO];
}
completion:nil];
The problem is during the transition. I have a kind of shadow on all the window view. I can change the color but the shadow stays. An example with a red background ([UIColor RedColor]):
Thank you
I am trying to create a scale animation for my view controller presentation
what i have is
UIViewController *vc =[[UIViewController alloc]initWithNibName:#"nextVC" bundle:[NSBundle mainBundle]];
[vc willMoveToParentViewController:self];
[self addChildViewController:vc];
[self transitionFromViewController:currentViewController toViewController:vc duration:2 options:0 animations:^(void){
vc.view.layer.anchorPoint = currentViewController.view.frame.origin;
vc.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
vc.view.frame = currentViewController.view.frame;
}completion:^(BOOL finished){
[vc didMoveToParentViewController:self];
}];
now this code works, the view controller is presented.
but instead of doing the right scale i want, it comes flying in from the bottom right corner.
how do i make it sort of unfold from the top margin to the bottom margin
How to Flip animation when navigation is controller popped, how we can achieve this
Following code for the flip animation for pop view
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
Following code for the Animation Block
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:transition forView:self.navigationController.view cache:NO];
}];
[self.navigationController popViewControllerAnimated:NO];
Try This Below Code to Push your View to next view.
-(IBAction)gotonextView:(id)sender
{
NextView *info = [[NextView alloc]initWithNibName:#"NextView" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:info];
info.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController presentModalViewController:nvc animated:YES];
}
Automatically You will get the same flip animation while popping out.
I'm pushing a view controller that contains a tableiview onto my uinavigation controller:
CourseMenuViewController *mvc = [[[CourseMenuViewController alloc] initWithSlidingNavigationcontroller:self.slidingNavigationController] autorelease];
mvc.course = course;
[self.navigationController pushViewController:mvc animated:YES];
[self.navigationController setNavigationBarHidden:NO animated:NO];
So far so good, everything works as expected. My issue occurs when I watch the animation and see all of my table view rows animate down from the top of the screen as the view is animating in from the left. This makes it feel like the view is moving from the top-left corner to the bottom-right corner in a diagonal path.
My question is, how can I make the table view just appear instead of animating? I should add that all of my cells are static so I'm not waiting on any data from a NSFetchedResultsController or anything like that.
roronoa below put me on the right path, and here is the now working version:
CourseMenuViewController *mvc = [[[CourseMenuViewController alloc] initWithSlidingNavigationcontroller:self.slidingNavigationController] autorelease];
mvc.course = course;
CATransition *caTransition = [CATransition animation];
caTransition.duration = 0.35;
caTransition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
caTransition.delegate = self;
caTransition.type = kCATransitionPush;
caTransition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:caTransition forKey:nil];
[self.navigationController pushViewController:mvc animated:NO];
You have not mentioned details about your class CourseMenuViewController and initWithSlidingNavigationcontroller , but you can use the following to get the job done:-
CourseMenuViewController *mvc =[[CourseMenuViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[self.navigationController pushViewController:mvc animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[mvc release];
you can have any type of animation that you want in the above code by changing the animation constants according to your need without having unwanted animations on your tableview.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
alarmViewController = [[AlarmViewController alloc] init];
[self.navigationController pushViewController:alarmViewController animated:YES];
[alarmViewController release];
[UIView commitAnimations];
I just want the viewcontroller flip like opening a book page,but it does not work like this.And I have a question that whether navigationController can animate this effect?
Since you are already putting the navigationController in an animation block. Mark animated:NO -
[self.navigationController pushViewController:alarmViewController animated:NO];
when we actually call pushViewController: we are setting the animated value to NO. This disables the Navigation Controller's default animation. Instead, the block of code uses the defined transition.