gpt4 book ai didi

ios - UIPopoverController 中 UINavigationBar 的色调颜色不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:58 25 4
gpt4 key购买 nike

代码:

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 的 tint 颜色属性不起作用,它仍然具有默认颜色。我可能做错了什么?

最佳答案

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

关于ios - UIPopoverController 中 UINavigationBar 的色调颜色不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7346715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com