每當用戶想要選擇默認未列出的新共享方法或操作時,通過點擊UIActivityViewController生成的共享表上的「更多」按鈕,會顯示一個新視圖,如下所示:如何在用戶點擊UIActivityViewController上的「更多」時設置導航欄顏色?
正如你所看到的,導航欄itens是白色的,而它的背景是淺灰色的。如何更改這些顏色以反映我的應用UI?
每當用戶想要選擇默認未列出的新共享方法或操作時,通過點擊UIActivityViewController生成的共享表上的「更多」按鈕,會顯示一個新視圖,如下所示:如何在用戶點擊UIActivityViewController上的「更多」時設置導航欄顏色?
正如你所看到的,導航欄itens是白色的,而它的背景是淺灰色的。如何更改這些顏色以反映我的應用UI?
設置導航欄上的tintColor
和barTintColor
:
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
tintColor
是導航項目和欄按鈕項目 barTintColor
如果導航欄的背景。
集此屬性的模式開幕前,是這樣的:
modal.navigationController.navigationBar.barTintColor = ...
能否請您提供一些代碼,讓我們看看你現在正在努力?
我做這個和它的作品對我來說:
Sublclass 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();
}
}];
}
您可能使用UIAppearance選擇器來修改你的應用程序的所有導航欄,通過調用它的類。相反,請調用單個對象的外觀方法,這樣可以避免系統導航欄像這樣着色。
這會更改分享工作表上的條形,但當點按「更多」按鈕時,模式將以不同的條形顏色打開。 – 2015-01-09 20:17:59