2

As titled, in iOS7, How to change navigation bar background/color in UIPopoverController?

I'm using the following way, but does not work

UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:packListViewController];
    [navController.navigationBar setBarTintColor:[UIColor blackColor]];

    if (_packListPickerPopover == nil) {
        _packListPickerPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
        _packListPickerPopover.popoverContentSize = CGSizeMake(950, 345);
    }

Thanks a lot

LiangWang
  • 8,038
  • 8
  • 41
  • 54
  • 1
    duplicate: http://stackoverflow.com/questions/8490261/change-color-navigation-controller-in-a-popover – Jatin Nov 05 '13 at 02:50
  • @Jatin, Thanks, i went through that topic before this thread. And I'm wondering whether there's some simple ways to do that (in that topic, it's too complicated) – LiangWang Nov 05 '13 at 02:58
  • 3
    @Jacky actually this question is probably more closely related: http://stackoverflow.com/questions/19095195/ios7-navigatinbar-tintcolor-change-in-popover and the top answer worked for me – imnk Nov 13 '13 at 12:02

1 Answers1

7

iOS 7 onwards, you can use backgroundColor property of UIPopoverController.

@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