3
votes

In this answer on Stack Overflow, Display clearColor UIViewController over UIViewController, the user suggests using the Over Current Context option for a modal view controller.

The goal is to create a transparent modal view controller, all through Storyboard.

But the Over Current Context option isn't available. Only Current Context, which doesn't create a transparent modal controller.

3

3 Answers

2
votes

Been wrestling with this same issue for some time, and finally found a workaround.

Using Xcode 7.2.

Not sure exactly why this is happening, but Over Current Context is not an available option. This project was created some time ago, which I have a hunch could be related.

current context

As a test, I created a brand new project, and Over Current Context is an option.

over current context

Since deleting and recreating my existing project was out of the question, I ended up doing the following:

  1. Set the Presentation on the segue to Default. This is preparation for the next step.

  2. On the destination view controller scene, set Presentation to Over Current Context within the Attributes Inspector.

destination view controller

I was able to successfully see the parent view controller underneath the semi-transparent modal.

Note:

I'm supporting iOS 8 and above, so I don't have to mess around with setting the modalPresentationStyle on the parent vs. the child.

Failed attempts:

  • Setting modalPresentationStyle to .OverCurrentContext on the destination view controller in prepareForSegue did not work for me, because the Storyboard setting seemed to override my code.

  • Setting Defines Context and Provides Context did not seem to make a difference. I'm guessing these could come into play for some app architectures, just not my in my particular project.

0
votes

Are you supporting iOS 7? Over Current Context is iOS 8 only.

0
votes

IOS 7 can totally handle Over Current context, just be sure to check use size classes on the File inspector.

Example here: