2

我有图 1 中显示的主视图控制器。

图 1

当用户单击条形按钮时,使用presentViewController:方法呈现另一个视图控制器。这CNContactPickerViewController是完全原生的(如图 2 所示)。

图 2

如何更改此控制器的 UINavigationBar 的颜色?我尝试了以下方法但没有奏效:

  1. 更改 Appdelegate 中的导航栏颜色
  2. 更改了控制器继承的全局文件中的导航栏颜色。

我使用了以下代码:

 [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 不会在导航栏上显示组按钮,如模拟器所示。

如何改变颜色Cancel button on CNContactPickerViewController

上面的问题我已经有了答案。现在,悬而未决的事情是如何更改 tableview部分的颜色以及CNContactPickerViewController.

4

1 回答 1

4

最终,经过大量的研发,我得到了它。我使用下面的代码来制作红色的导航栏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];
于 2016-05-27T05:21:50.930 回答