How to make uiview fullscreen viewcontroller using

2019-06-08 08:19发布

问题:

What i want to achieve is: after tapping a small view with some data i want to make it full screen and possibly make it to be a new vc.

For now I animate uiview to full screen with great success, but whole logic of this view is in it's "parent".

Is it possible to animate viewcontroller out of the uiview which is similar (for. eg. like in LayoutTransitions in Android SDK)?

Sample code of my uiview to full screen using autolayout:

            sender.view.transform = CGAffineTransformIdentity;
            [UIView animateWithDuration:0.2
                             animations:^{
                                 sender.view.frame = self.view.window.bounds;
                             } completion:^(BOOL finished) {
                                 [((CSTicketView*)sender.view) showMenu];
                             }];
            [[UIApplication sharedApplication]
             setStatusBarHidden:YES
             withAnimation:UIStatusBarAnimationFade];
            [[self navigationController] setNavigationBarHidden:YES animated:YES];

回答1:

Absolutely possible. You can use the new view controller transitions model in iOS7. I would definitely recommend a few resources to check on top of my basic explanation:

  • this
  • and this
  • I have some sample code for a demonstrator of this here

Ultimately you make a new view controller for the view you are transitioning to, and you also make an NSObject subclass that conforms to UIViewControllerAnimatedTransitioning which contains the code to transition between them. Sounds complex but if you watch the video I linked to and read the other reference it'll make total sense.



回答2:

Let's move your sender view to Window as like below,

AppDelegate * appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];

[appDelegate.window addSubview:sender.view];

[UIView animateWithDuration:0.2
                             animations:^{
                                 sender.view.frame = self.view.window.bounds;
                             } completion:^(BOOL finished) {
                                 [((CSTicketView*)sender.view) showMenu];
                             }];