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

后端 未结 8 1054
陌清茗
陌清茗 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.)

提交回复
热议问题