ios9 - 更改 CNContactPickerViewController iOS 的导航栏颜色

标签 ios9 navigationcontroller cncontact cncontactviewcontroller

我的主视图 Controller 如图 1 所示。

Image 1

当用户单击栏按钮时,会使用 presentViewController: 方法呈现另一个 View Controller 。这是完全原生的 CNContactPickerViewController(如图 2 所示)。

Image 2

如何更改此 Controller 的 UINavigationBar 的颜色? 我尝试过以下方法但没有成功:

  1. 更改了 Appdelegate 中的导航栏颜色
  2. 更改了 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/

相关文章:

ios - 如何解决 Type of expression is ambiguous without more context for an audio recorder in swift 2

ios9 - 如何创建 View 之间具有可变间距的 UIStackView?

ios - FBSDK 安全网络请求失败 iOS9

ios - parentViewController 和presentingViewController 都为零

protocols - Swift 2 在协议(protocol)扩展 "Cannot use mutating member on immutable value: ' self' 中使用变异函数时出错

core-data - 'NSInternalInconsistencyException',原因 : '+entityForName: could not locate an NSManagedObjectModel for entity name

ios - 释放一个navigationItem

ios - CNContactPickerViewController 即使在禁用设置访问后也会显示

ios - 使用联系人框架创建新组,CNErrorDomain Code = 2

ios - 如何在没有过滤器的情况下从设备中检索所有 CNContactStore