2015-10-20 55 views
1

如何自定義CNContactPickerViewController的UI?在iOS 9中自定義ContactPicker UI

我想改變顏色,字體和文本 - 類似於如何完成了嗎?

enter image description here

目前 - 我CNContactPickerViewController長相酷似蘋果的本地聯繫人應用程序。

回答

1

首先從地址簿中的聯繫人,並將它們傳遞到NSArray

CNContactStore *store = [[CNContactStore alloc] init]; 
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { 

    NSMutableArray *contacts = [NSMutableArray array]; 

    NSError *fetchError; 
    CNContactFetchRequest *request = [[CNContactFetchRequest alloc] initWithKeysToFetch:@[CNContactIdentifierKey, [CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName]]]; 

    BOOL success = [store enumerateContactsWithFetchRequest:request error:&fetchError usingBlock:^(CNContact *contact, BOOL *stop) { 
     [contacts addObject:contact]; 
    }]; 
    if (!success) { 
     NSLog(@"error = %@", fetchError); 
    } 
}]; 

然後,只需在UITableView使用NSArray,並從那裏你可以自定義字體,顏色等