ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.topViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
[self presentViewController:picker animated:YES completion:nil];
搜索欄不在導航欄層級,需遞歸查找:
- (void)customizeSearchBar:(UINavigationController *)nc {
for (UIView *view in nc.topViewController.view.subviews) {
if ([view isKindOfClass:[UISearchBar class]]) {
[(UISearchBar *)view setTintColor:[UIColor blackColor]];
break;
}
}
}
// 在 present 後調用,或實現 UINavigationControllerDelegate
ABPeoplePickerNavigationController 已棄用(iOS 9+),推薦使用 CNContactPickerViewController (ContactsUI 框架),支持完整外觀定製且符合隱私權限機制。