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

后端 未结 8 1059
陌清茗
陌清茗 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 11:51

    From the Documentation:

    UIModalTransitionStylePartialCurl

    When the view controller is presented, one corner of the current view curls up to reveal the modal view underneath. On dismissal, the curled up page unfurls itself back on top of the modal view. A modal view presented using this transition is itself prevented from presenting any additional modal views.

    This transition style is supported only if the parent view controller is presenting a full-screen view and you use the UIModalPresentationFullScreen modal presentation style. Attempting to use a different form factor for the parent view or a different presentation style triggers an exception.

    Although, I haven't got any exception using other presentations than full screen. I was testing out and I get the same problem as you. I found that if my ParentViewController's view is an ImageView and I set the content mode to UIViewContentModeCenter, the view is not resized or moved. Maybe there is a workaround by saving your current view as an image, put it at the top, make the curl, and after you dismiss your modal, rearrange the messed hidden stuff and remove the top image view. I know that it sounds crazy but that is what I would try if I really had to accomplish that requirement.

    Hope this helps, Jorge.

提交回复
热议问题