每当用户想要选择默认情况下未列出的新共享方法或操作时,只需点击“更多”" UIActivityViewController生成的共享表上的按钮,将显示一个新视图,如下所示:
如您所见,导航栏显示为白色,而背景为浅灰色。如何更改这些颜色以反映我的应用UI?
答案 0 :(得分:5)
我这样做了,对我有用:
子类UIActivityViewController
并覆盖-(void)presentViewController:animated:completion:
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
[viewControllerToPresent.view setTintColor:[[UINavigationBar appearance] tintColor]];
for (UIView *view in viewControllerToPresent.view.subviews) {
if ([view isKindOfClass:[UINavigationBar class]]) {
UINavigationBar *navigationBar = (UINavigationBar*)view;
UIImage *navigationBarImage = [[UINavigationBar appearance] backgroundImageForBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[navigationBar setBackgroundImage:navigationBarImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[navigationBar setTitleTextAttributes:[[UINavigationBar appearance] titleTextAttributes]];
}
}
[super presentViewController:viewControllerToPresent animated:flag completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
if (completion) {
completion();
}
}];
}
答案 1 :(得分:1)
在打开之前在模态上设置此属性,如:
modal.navigationController.navigationBar.barTintColor = ...
您能为我们提供一些代码,以便了解您现在正在尝试的内容吗?
答案 2 :(得分:0)
在导航栏上设置tintColor
和barTintColor
:
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
tintColor
用于导航项和栏按钮项
barTintColor
如果是导航栏背景。
答案 3 :(得分:0)
您可能正在使用UIAppearance选择器通过在类上调用它来修改应用程序上的所有导航栏。相反,在单个对象上调用外观方法,这将使系统导航栏不会像这样被着色。