Victor Ronin Victor Ronin - 8 months ago 110
Swift Question

How to make UIPopoverPresentationController semi transparent for iOS 9

I used IB to create a segue to present another view a popover.

I added a code in

to deletage UIPopoverPresentationControllerDelegate to initial controller.

And I set presentation style:

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController,
traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return UIModalPresentationStyle.None

This gives me a nice standard popover.

However, I want to make a semi-transparent popover.

I tried couple of things:

  • I set background color in IB to "clear"

  • I tried to set a alpha on the popover view

Answer Source

To have a view controller on top of another with transparency, you'll need to return UIModalPresentationStyle.OverCurrentContext.