Reputation: 123
I am trying to develop a iphone application. I know how to slide a view from left to right while pushing into navigation stack. But my requirement is to animate the view from top to bottom while pushing into navigation stack. So how to do that?
I am searching google but have not found any satisfying result.. If somebody knows it... Please tell me how to do that.
info = [[InfoView alloc] initWithNibName:@"InfoView" bundle:nil];
[self.navigationController pushViewController:info animated:YES];
Upvotes: 1
Views: 2071
Reputation: 542
You can try something like this while pushing your viewcontroller to the navigation stack:
SecondViewController *VC2 = [[SecondViewController alloc]init];
VC2.nameSupplied = self.nameField.text;
CGPoint mycenter = VC2.view.center;
CGPoint navCenter = self.navigationController.navigationBar.center;
VC2.view.center = CGPointMake(mycenter.x , mycenter.y - VC2.view.frame.size.height);
self.navigationController.navigationBar.center = CGPointMake(navCenter.x, navCenter.y - self.navigationController.navigationBar.frame.size.height);
[self.navigationController pushViewController:VC2 animated:NO];
[UIView animateWithDuration:0.5
delay:0
options: UIViewAnimationCurveEaseOut
animations:^{
VC2.view.center = mycenter;
self.navigationController.navigationBar.center = navCenter;
}
completion:^(BOOL finished){
NSLog(@"Animation Done!");
}];
However if you want to just show another view(moving top to bottom) in the same view controller , you can use tranform property of UIView like this :
self.secondView.transform = CGAffineTransformMakeTranslation(0, secondView.frame.size.height);
Upvotes: 2