如何自定义CNContactPickerViewController的UI?
我想改变颜色,字体和文字 - 类似于Snapchat的做法?
目前 - 我的CNContactPickerViewController看起来与Apple的原生联系人应用程序完全相同。
答案 0 :(得分: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);
}
}];
然后只需使用NSArray
中的UITableView
,然后就可以自定义字体,颜色等。