Is there a way to make the UIPopOver transparent (alpha = 0.75 or so). Unfortunately there is no alpha property for UIPopOver. I need to present a popover so that the view beneath it will still be partially visible. Any ideas
5 Answers
Starting with iOS5.0, one can provide a custom background for the UIPopoverController
. That background has to be derived from UIPopoverBackgroundView
which does provide the normal UIView
properties like alpha
.
Note that the name is a bit confusing - the UIPopoverBackgroundView
provides the frame-, the arrow- as well as the background-graphics.
So if you need an entirely semi-transparent UIPopoverController
, all you have to do is supply a UIPopoverBackgroundView
class which sets its alpha
towards something below 1.0
. You will also need to make sure that your contentViewController's view is (fully) transparent.
Example:
For details, see the popoverBackgroundViewClass
property of UIPopoverController
:
popoverBackgroundViewClass
The class to use for displaying the popover background content.
@property (nonatomic, readwrite, retain) Class popoverBackgroundViewClass
Discussion
The default value of this property is nil, which indicates that the popover controller should use the default popover appearance. Setting this property to a value other than nil causes the popover controller to use the specified class to draw the popover’s background content. The class you specify must be a subclass of UIPopoverBackgroundView.
Availability Available in iOS 5.0 and later. Declared In UIPopoverController.h

- 27,559
- 13
- 88
- 122
-
Havent used it yet but good to see there is finally more to customize of a UIPopover – Jasper Apr 17 '13 at 13:49
-
3This support was deprecated in iOS 9.0. Don't suppose anyone knows if there is a newer way? – John Bushnell Mar 21 '16 at 19:51
popoverController.contentViewController.view.alpha = 0.5;
alpha is an property of an UIView so you need to get the view of the popOver and then set the alpha to that view.

- 12,006
- 5
- 51
- 71
There is currently no property to set the alpha of a UIPopoverController
.
If you do: popoverController.contentViewController.view.alpha = 0.5;
The inside view & content will be transparant and not the UIPopoverController
itself.
For iOS 13:
There seems to be an opaque subview with a dark gray background of type _UIPopoverStandardChromeView with no API means for controlling it (Apple bug?). To make the popover transparent, you may needed to the add the hack below to the presented view controller. It must be done in or after the viewDidAppear(_:) call. It didn't work in viewWillAppear(_:) or earlier calls.
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Only works in viewDidAppear()
self.popoverPresentationController?.containerView?.subviews.last?.subviews.first?.alpha = 0
}

- 51
- 2
-
Thank you for this. I spent hours trying to figure this out and saw your answer as I discovered it myself in the view hierarchy tool. In addition, I got this to work in viewDidLayoutSubviews! – user13138159 May 21 '20 at 06:27
You can now use the backgroundColour property of the popoverPresentationController to do this, e.g.
if let popoverPresentationController = myController.popoverPresentationController {
popoverPresentationController.backgroundColor = UIColor(white: 1, alpha: 0.5)
}
(don't forget to set the view in the popover and controls in that view to transparent as well as appropriate to the effect you are trying to acheive)
See this SO answer for more details.

- 1
- 1

- 4,486
- 3
- 30
- 55