Customizing the UIPopoverController view background and border color
Solution 1
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.
Solution 2
iOS 7 onwards, you can change backgroundColor
of UIPopoverController
which affects the navigation background color as well as arrows of popover.
@property (nonatomic, copy) UIColor *backgroundColor NS_AVAILABLE_IOS(7_0);
Usage example:
if ([self.popoverVC respondsToSelector:@selector(setBackgroundColor:)]) { // Check to avoid app crash prior to iOS 7
self.popoverVC.backgroundColor = [UIColor greenColor];
}
Note - As of now (iOS 7.0.3), in some cases (like set color using colorWithPatternImage:), the simulator doesn't honor the color but on device it works fine.
Solution 3
Now in iOS 5, popoverBackgroundViewClass is available.
Solution 4
From ios 5 onward you can do much just try this library https://github.com/ddebin/DDPopoverBackgroundView you can customise border tint color, bodrer width as well as arrow
look at the documentation
Mustafa
I'm a Manager Development/Project Manager/Team Lead/Mobile Application Developer located in Islamabad, Pakistan, working for BroadPeak Technologies. I'm currently focusing on managing and developing mobile applications for Android and iOS devices; with hands on experience developing iOS applications. More information.
Updated on July 05, 2020Comments
-
Mustafa almost 4 years
Is it possible to change the border color, navigation bar style/color, and arrow style/color of a pop over view? If so, how? If some sample code is available, then that'll be great!
-
mjisrawi almost 13 yearsModifying the unexposed view hierarchy is probably a bad idea, even if your app is accepted. Should the view be modified by Apple in the future, your code would suddenly stop working.
-
Jesse Black over 11 yearsYou might want to link to your dup answer at stackoverflow.com/a/7063257/1015071
-
Yunus Nedim Mehel over 10 yearsThis is no longer valid, after iOS5 popoverBackgroundView can be subclassed, here is a good one I have just used: github.com/GiK/GIKPopoverBackgroundView
-
timgcarlson over 10 yearsYep, if you only need to change the background of the popover (including the arrow), this is the quickest way to do it. Much better than subclassing
UIPopoverBackgroundView
for a simple change. -
Ashok over 10 yearsNote- above one is old/outdated answer. Now in iOS 7, for navigation bar and arrow color changes,
UIPopoverController
has introducedbackgroundColor
as property. See my answer below. -
arlomedia over 10 yearsNote that if the view you're displaying inside the popover has its own background color, you will only see the popover's background color on the arrow.
-
anders about 8 yearsFor simple customizations (IE changing arrow color) this should be the accepted answer!