I would like to push a view controller using Swift and animate it so it appears from the bottom and moves up. I have the following code to push my view controller:
let helloTableViewController = self.storyboard!.instantiateViewControllerWithIdentifier("helloTableViewController") as! HelloTableViewController
self.navigationController!.pushViewController(helloTableViewController, animated: true)
I have found the following from another question but cannot seem to get it to work in Swift:
CATransition *animation = [CATransition animation];
[animation setDuration:2];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
SecondView *sObj=[[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
[self.navigationController pushViewController:sObj animated:YES];
[[sObj.view layer] addAnimation:animation forKey:@"SwitchToView1"];
SecondView
), and these days the above transition could more easily (should) be written using theUIView
transitionWithView
/transitionFromView
method. – Halden