16

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!

Mustafa
  • 20,504
  • 42
  • 146
  • 209

7 Answers7

43

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.

Ashok
  • 6,224
  • 2
  • 37
  • 55
  • Yep, 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. – timgcarlson Feb 03 '14 at 20:04
  • Note 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. – arlomedia Mar 07 '14 at 03:39
  • For simple customizations (IE changing arrow color) this should be the accepted answer! – anders Jun 08 '16 at 17:25
5

Now in iOS 5, popoverBackgroundViewClass is available.

akaru
  • 6,299
  • 9
  • 63
  • 102
2

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.

Community
  • 1
  • 1
bdunagan
  • 1,202
  • 12
  • 15
  • 2
    This is no longer valid, after iOS5 popoverBackgroundView can be subclassed, here is a good one I have just used: https://github.com/GiK/GIKPopoverBackgroundView – Yunus Nedim Mehel Dec 10 '13 at 08:20
  • Note- above one is old/outdated answer. Now in iOS 7, for navigation bar and arrow color changes, `UIPopoverController` has introduced `backgroundColor` as property. See my answer below. – Ashok Feb 14 '14 at 02:01
1

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

Kshitiz Ghimire
  • 1,716
  • 3
  • 18
  • 37
0

You can use ElegantPopover cocoapod to accomplish some of that.

0

The navigation bar and tool bar inside a popover are just a standard UINavigationBar and UIToolBar, I've had success in changing their appearance just as you would with a normal nav bar or tool bar. The border however is not easily customizable.

mjisrawi
  • 7,846
  • 3
  • 24
  • 27
-2

I try to trick it by customizing the viewcontroller inside the popover and then hiding the popover border using this code

UIView * border = [[insideViewController.view.superview.superview.superview subviews] objectAtIndex:0];  
border.hidden = YES;

The app is actually still in development so I'm hoping other people will comment on this solution.

agf
  • 171,228
  • 44
  • 289
  • 238
vangoz
  • 546
  • 6
  • 15
  • 4
    Modifying 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. – mjisrawi Aug 15 '11 at 09:51
  • You might want to link to your dup answer at http://stackoverflow.com/a/7063257/1015071 – Jesse Black Sep 29 '12 at 20:47