更改CNContactPickerViewController iOS的导航栏颜色

时间:2016-05-26 05:38:20

标签: ios9 navigationcontroller cncontact cncontactviewcontroller

我在图像1中显示了家庭视图控制器。

Image 1

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

Image 2

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

  1. 更改了Appdelegate中的导航栏颜色
  2. 更改了控制器继承的全局文件中的导航栏颜色。
  3. 我使用了以下代码:

     [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的颜色?

    我已经回答了上述问题。现在,待处理的事情是如何更改CNContactPickerViewController的tableview部分以及的颜色。

1 个答案:

答案 0 :(得分:4)

最后,我在做了很多R& D之后得到了它。我使用下面的代码制作了 [[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]; 红色的导航栏

{{1}}