Цвет оттенка UINavigationBar в UIPopoverController не работает - PullRequest
2 голосов
/ 08 сентября 2011

Код:

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];

Свойство цвета оттенка UINavigationBar не работает, оно по-прежнему имеет цвет по умолчанию.Что я могу делать не так?

Ответы [ 2 ]

5 голосов
/ 16 ноября 2011
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
3 голосов
/ 03 ноября 2011

Начиная с iOS 5, доступен popoverBackgroundViewClass, который является способом для достижения этой цели.

...