How can I use UIModalTransitionStylePartialCurl on a UIView that does NOT take up the whole screen?

后端 未结 8 1053
陌清茗
陌清茗 2021-01-30 11:06

In Apple\'s official Maps app for the iPhone, there is a small \'page curl\' button in the lower-right corner. When you press it, the map itself peels back to reveal some optio

相关标签:
8条回答
  • 2021-01-30 12:03

    As cprcrack points out, this doesn't answer the original question. However, it's useful information, so with that in mind I'm going to leave it here.

    This is actually much simpler than you'd guess.

    We'll call the view controllers MapViewController and SettingsViewController. Your problem is you want to peel back part (and only part) of MapViewController to show SettingsViewController.

    Here's how you do it:

    • Use a full size view for both views.
    • Only put content on the bottom half of SettingsViewController's view.
    • Use UIModalTransitionStylePartialCurl to transition between them, like you already are.

    iOS will detect that you've done this automatically and only peel MapViewController's view back far enough to the bottom half of SettingsViewController's view, which is where all your content is.

    If you put content in the top half of SettingsViewController's view, iOS will detect that and peel back MapViewControllers view all the way instead.

    Summary: Put content only in the bottom half of your new view. iOS will figure it out.

    (I don't think this is documented anywhere, sorry.)

    0 讨论(0)
  • 2021-01-30 12:05

    Override the viewWillDisappear method of your underMapViewController with something like this:

    - (void)viewWillDisappear:(BOOL)animated
    {
        curlableMapViewController.view.frame = CGRectMake(0.f, 0.f, 320.f, 416.f);
    
        [super viewWillDisappear:animated];
    }
    

    That corrects the size of the view of the curlableMapViewController to the know size you specify, which you could save earlier in the viewWillAppear method, for example.

    0 讨论(0)
提交回复
热议问题