首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

iOS ABPeoplePickerNavigationController 導航欄顏色定製

     編輯:程式設計綜合問答

基本設置

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];

搜索欄顏色同步(iOS 7+)

搜索欄不在導航欄層級,需遞歸查找:

- (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 框架),支持完整外觀定製且符合隱私權限機制。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved