UIPopoverPresentationController darkening background darker

I want a darker dull color for UIPopover

. I know this can be achieved by subclassing UIPopoverBackgroundView

as mentioned here , but I'm looking for an easier way to do it.

PS I am using Objective C not Swift .

+3


source to share


3 answers


The easiest way is to just call the self.view.alpha = 0.2

popover before submitting and set it back to 1.0 when the popover is rejected.



+2


source


Swift 4

I just ran into the same problem and found a solution similar to jimmyjudas.



The viewController is 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
    }

      

+1


source


UIPopover does not have a background property because the NSObject subclass has no view property setting so you can change the color of your content -

 UIPopoverController *popC = [[UIPopoverController alloc] initWithContentViewController:TestingPC];
[[[popC contentViewController]  view] setBackgroundColor:[UIColor blackcolor]];

      

0


source







All Articles