PresentViewController with custom transition

I would like to present a modal UIViewController with various transitions to those available by the toolkit. Precisely I would like an upside-down animation compared to the slide from the bottom (UIModalTransitionStyleCoverVertical), present = slide from the top, firing = slide from the top.

I don't think there is an easy option to invert the UIModalTransitionStyleCoverVertical, so I think I need to do it myself.

I also don't use segue / storyboard, not sure if that matters.

I've found some solutions that suggest just animating a new view of the viewcontroller and using the presentViewController with the animated option as NO. Unfortunately, the problem is that the background goes black right away, even if I define a new viewcontroller with a clear background and not opaque.

Any idea how I could sort this out? Many thanks!

+3


source to share


2 answers


I solved the opaque background problem by taking a screenshot and using it as the background for the modal controller.



+1


source


  • Apply your own animation with CATransition.

  • Set the property modalPresentationStyle

    for the presented view controller to UIModalPresentationCustom (available for iOS 7 or later). See also UIModalPresentationOverCurrentContext iOS8 or UIModalPresentationCurrentContext.



In my case, I wanted to have the same animation style, but I needed to use the UIModalPresentationOverCurrentContext for iOS 8.

0


source







All Articles