gpt4 book ai didi

ios - UIDocumentInteractionController 导航栏颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:21:50 24 4
gpt4 key购买 nike

在我的 iOS 应用程序中,我使用 DocumentInteractionController 来预览 .csv 文档。

    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileLocation];
[self.documentController setDelegate:self];
[self.documentController presentPreviewAnimated:YES];

但是,我发现导航栏是完全透明的。后退按钮是白色的,因此由于白色背景而不可见。

请注意,我在 AppDelegate 中设置了导航栏的样式:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0/255.0f green:138/255.0f blue:188/255.0f alpha:1.0f]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"DINPro-Bold" size:17]}];
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"shadow"]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

本质上,我的问题是如何使 DocumentInteractionController View Controller 中的导航栏外观与整个应用程序中的导航栏外观一致(或至少可见!)。

最佳答案

此行将透明(或更确切地说是空的)背景图像放置到您的 UINavigationBar。这是为什么?

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

只需移除线路,一切正常。

如果你想设置阴影图像,那么你应该考虑使用 appearanceWhenContainedIn: 而不是 appearance 这样它就不会传播到未处理的 Controller 。

至于状态栏样式,最简单的方法是将 self.navigationController 作为演示者传递,而不是 self:

- (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
return self.navigationController;
}

希望对你有帮助

关于ios - UIDocumentInteractionController 导航栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25083859/

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