Clicking view controller with custom animation
2 answers
This can of course be done. I made a project where I did it like this:
-(void)slideInController:(RDSlideController *) next {
next.presentingVC = self;
next.view.frame = CGRectMake(self.view.frame.origin.x + 320, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
[self.view.window addSubview:next.view];
[UIView animateWithDuration:slideTime animations:^{
next.view.frame = self.view.frame;
} completion:^(BOOL finished) {
self.view.window.rootViewController = next;
}];
}
The view controllers that I moved to were subclasses of RDSlideController (so I could have a presentingVC property and some other stuff), but that's not necessary. Basically, you just instantiate a new controller, set its view frame to the screen on the right, add that view to the window, and then animate the frame to the current view frame. Finally, you turn off the view controllers so that the new one is now the window's root view controller.
0
source to share