0

I have a problem like in this question, but answers don't help me. I want that colors navigation bar in seconds screen will be like a first screen. iOS 9 or later.


    - (void) showAdressBookActionForIOSNineOrLater {
    CNContactPickerViewController * newPicker = [[CNContactPickerViewController alloc] init];
    newPicker.delegate = self;

    NSDictionary *attributesNormal = [NSDictionary dictionaryWithObjectsAndKeys:
                                      [UIFont appFont_Headline], NSFontAttributeName,
                                      [UIColor appColor_white_0], NSForegroundColorAttributeName, nil]; 
//appColor_white_0 my custom color APP_RGBA(255.0f, 255.0f, 255.0f, 1.0f); appFont_Headline - [UIFont HelveticaNeueRegularFont:fontSize];

    newPicker.navigationController.navigationBar.titleTextAttributes = attributesNormal;
    newPicker.navigationController.navigationBar.translucent = NO;
    newPicker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    newPicker.navigationController.navigationBar.tintColor = [UIColor appColor_white_0];


    [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
    [[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTintColor:[UIColor appColor_white_0]];
    [[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setBarTintColor:[UIColor appColor_white_0]];
    [[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setTitleTextAttributes:attributesNormal];


    newPicker.predicateForEnablingContact = [NSPredicate predicateWithFormat:@"phoneNumbers.@count > 0"];
    newPicker.predicateForSelectionOfContact = [NSPredicate predicateWithFormat:@"phoneNumbers.@count == 1"];
    newPicker.predicateForSelectionOfProperty = [NSPredicate predicateWithFormat:@"key == phoneNumber"];
    newPicker.displayedPropertyKeys = @[CNContactPhoneNumbersKey];
    //
    [[self currentNavigationController] presentViewController:newPicker animated:YES completion:nil];

And implement delegate methods:

- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty{
        CNContact *contact = contactProperty.contact;
        NSString *identify = contactProperty.identifier;
        NSString * selectedNumber = @"";
        for (CNLabeledValue<CNPhoneNumber*>* number in contact.phoneNumbers) {
           if ([number.identifier isEqualToString:identify]) {
        selectedNumber = ((CNPhoneNumber *)number.value).stringValue;
                                }
                            }                   [self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
                        }
- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker { 

    [self.currentNavigationController.presentedViewController dismissViewControllerAnimated:YES completion:nil];
                        }

Screen story:

first screendo choosepush to second screensecond screen

redisky
  • 97
  • 2
  • 11
  • Hi I never used this. But you have change to NavigationBar background colour. So try to get the key for background colour. – phani Aug 04 '17 at 08:21
  • 1
    [[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UINavigationController class]]] setBackGroundColor:[UIColor green]]; I don't know this key is available or not. Just try it. – phani Aug 04 '17 at 08:22
  • thank's, it's work for me – redisky Aug 07 '17 at 06:42

0 Answers0