Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPopoverPresentationController dimming background darker

I want darker background dim color for UIPopover. I know this can be achieved by subclassing UIPopoverBackgroundView as mentioned here but I am looking for any simpler way to do this.

P.S. I am using Objective C not Swift.

like image 728
Sasi Avatar asked Jul 24 '15 05:07

Sasi


2 Answers

Swift 4

I just came upon the same problem and found a solution similar to jimmyjudas.

In the viewController displayed as a popover:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.presentingViewController?.view.alpha = 0.3
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.presentingViewController?.view.alpha = 1
    }
like image 134
Trevor Avatar answered Nov 13 '22 09:11

Trevor


Easiest method is to simply call self.view.alpha = 0.2 before presenting the popover and setting it back to 1.0 when the popover is dismissed.

like image 3
Man Eating Monkey Avatar answered Nov 13 '22 08:11

Man Eating Monkey