简体   繁体   中英

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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM