我的主视图 Controller 如图 1 所示。
当用户单击栏按钮时,会使用 presentViewController:
方法呈现另一个 View Controller 。这是完全原生的 CNContactPickerViewController
(如图 2 所示)。
如何更改此 Controller 的 UINavigationBar 的颜色? 我尝试过以下方法但没有成功:
- 更改了 Appdelegate 中的导航栏颜色
- 更改了 Controller 继承的全局文件中的导航栏颜色。
我使用了以下代码:
[self.navigationBar setTranslucent:NO];
[self.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"]
forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[UIImage new]];
[self.navigationBar setTintColor:kBlackColor];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor], NSForegroundColorAttributeName,nil]];
此外,当我在 iPhone 6S iOS 9.3.2 设备上运行该应用程序时,CNContactPickerViewController 不会在导航栏上显示组按钮,如模拟器中所示。
如何更改 CNContactPickerViewController 上的取消按钮的颜色
?
我已经得到了上述问题的答案。现在,悬而未决的事情是如何更改CNContactPickerViewController
的tableview部分以及单元格的颜色。
最佳答案
经过大量的研发,我终于得到了它。我使用下面的代码将 CNContactPickerViewController
的导航栏设为红色。
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:213/255.0f green:38/255.0f blue:46/255.0f alpha:1.0]];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], NSForegroundColorAttributeName,nil]];
[[UINavigationBar appearance] setTintColor:kWhiteColor];
关于ios9 - 更改 CNContactPickerViewController iOS 的导航栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37452419/