Change Uipopoverview Background + Arrow Color

Change UIPopoverView background + arrow color

I found the solution. Subclassing is not necessary anymore with iOS8! The background can be accessed and changed like this from within the tableview -> navigation -> popoverPresentationController

    self.navigationController?.popoverPresentationController?.backgroundColor = UIColor.redColor()

More information about this in WWDC session 2014.

How to change UIPopoverPresentationController's arrow color without drawing my own

The UIPopoverPresentationController's backgroundColor property should handle that for you

Update

I've used this approach a number of times and have never seen what you have in your screenshot. Are you sure you are using popoverPresentationController.backgroundColor and not setting a different background color on a view or container? Below is screenshot of non-centered popover arrow. The view controller background is green, the popoverPresentationController.backgroundColor is red. Shown next to the code setting the value.

non-centered arrow on popover presentation controller

Update #2

I looked at the project you posted and found the problem (although I'm not entirely sure why it's the problem). You are setting the popover presentation controller's backgroundColor property inside your presented view controller under viewWillAppear:. I suspect that setting the background color like this after the presentation happened is what triggers the bug pre-iOS 10.

If you set the popover presentation controller's backgroundColor inside your presenting view controller's onPopover: method, where you are also setting the sourceView and sourceRect properties (and before you actually call presentViewController:), everything works correctly.

How to change the arrow color in UIPopoverPresentionController iOS 8?

The simplest way is to set the popover presentation controller's backgroundColor. If that isn't good enough, you can set its popoverBackgroundViewClass, which gives you total command of the chrome including the arrow (but is a lot more work to implement).

Customizing the UIPopoverController view background and border color

Unfortunately, UIPopoverController is not customizable like that. You can't change the border color, navigation bar style/color, or arrow style/color: How to customize / style a UIPopoverController.

How to set clearColor for UIPopover View?

If what you're talking about is a UIPopoverController, then try setting the background color to its content view controller's view.

myPopover.contentViewController.view.backgroundColor = [UIColor clearColor];

Also, check this SO post about custom popover backgrounds.



Related Topics



Leave a reply



Submit