UIPopoverController中UINavigationBar的色调不起作用

Ale*_*x87 2 uinavigationbar uinavigationcontroller uipopovercontroller tintcolor ios

代码:

UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"NibName" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
navigationController.navigationBar.tintColor = [UIColor redColor];
self.popoverController = [[[UIPopoverController alloc]     
initWithContentViewController:navigationController] autorelease];
popoverController.popoverContentSize = viewController.view.frame.size;
[popoverController presentPopoverFromRect:sender.frame inView:sender.superview
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[viewController release];
[navigationController release];
Run Code Online (Sandbox Code Playgroud)

色调颜色属性UINavigationBar不起作用,它仍然具有默认颜色.我能做错什么?

Ale*_*x87 5

self.popoverController.popoverBackgroundViewClass = [MyCustomBackgroundView class];

@interface MyCustomBackgroundView : UIPopoverBackgroundView {
@private
}
@end

@implementation MyCustomBackgroundView

@synthesize arrowOffset;
@synthesize arrowDirection;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor redColor];
    }
    return self;
}

+ (UIEdgeInsets)contentViewInsets {
    return UIEdgeInsetsMake(0, 0, 1, 0);
}

+ (CGFloat)arrowHeight{
    return 0.0;
}

+ (CGFloat)arrowBase{
    return 0.0;
}

@end
Run Code Online (Sandbox Code Playgroud)