Clicking view controller with custom animation

Is it possible to create custom animations for a view controller like an image? The basic idea is to press down on the view normally, but not move the current view (which is calling pushViewController...

).

ex

+3


source to share


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


We can achieve this by adding a subview and an animation view that we want to add. When we add animation to move the next view from the left edge to the right edge. And vice versa, with the removal of the view.



0


source







All Articles