UIPopoverController 中 UINavigationBar 的色调不起作用

发布于 2024-12-03 23:00:16 字数 803 浏览 2 评论 0原文

代码:

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

The code:

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

The tint color property of UINavigationBar doesn't work, it still has the default color.
What could I be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ㄟ。诗瑗 2024-12-10 23:00:16
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
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
樱娆 2024-12-10 23:00:16

从 iOS 5 开始,popoverBackgroundViewClass 可用,这是实现此目的的方法。

As of iOS 5, popoverBackgroundViewClass is available which is the way to accomplish this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文