Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Last active April 20, 2026 09:07
Show Gist options
  • Select an option

  • Save barbietunnie/e5547f35180436ac102cac52a15f8ca3 to your computer and use it in GitHub Desktop.

Select an option

Save barbietunnie/e5547f35180436ac102cac52a15f8ca3 to your computer and use it in GitHub Desktop.

Revisions

  1. barbietunnie revised this gist Aug 27, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion modal-view.md
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,6 @@ Just add a Storyboard Seque with `Kind` set to `Present Modally` to your modal v
    As [Crashalot][1] pointed out in his comment: Make sure the **segue** only uses `Default` for both `Presentation` and `Transition`. Using `Current Context` for `Presentation` makes the modal turn black instead of remaining transparent.


    [1]: http://stackoverflow.com/users/144088/crashalot
    [1]: http://stackoverflow.com/users/144088/crashalot

    [Source](http://stackoverflow.com/a/33106533/499052)
  2. barbietunnie created this gist Aug 27, 2016.
    32 changes: 32 additions & 0 deletions modal-view.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    You can do it like this:

    **In your main view controller:**

    func showModal() {
    let modalViewController = ModalViewController()
    modalViewController.modalPresentationStyle = .OverCurrentContext
    presentViewController(modalViewController, animated: true, completion: nil)
    }

    **In your modal view controller:**

    class ModalViewController: UIViewController {
    override func viewDidLoad() {
    view.backgroundColor = UIColor.clearColor()
    view.opaque = false
    }
    }

    **If you are working with a storyboard:**

    Just add a Storyboard Seque with `Kind` set to `Present Modally` to your modal view controller and on this view controller set the following values:

    Background = Clear Color
    Drawing = Uncheck the Opaque checkbox
    Presentation = Over Current Context


    As [Crashalot][1] pointed out in his comment: Make sure the **segue** only uses `Default` for both `Presentation` and `Transition`. Using `Current Context` for `Presentation` makes the modal turn black instead of remaining transparent.


    [1]: http://stackoverflow.com/users/144088/crashalot