0

我在女巫中有一个标签栏控制器,我想嵌入一个 ABPeoplePickerNavigationController。我通过将此代码放在 viewDidLoad 中来做到这一点

[super viewDidLoad];
_addressBookController = [[ABPeoplePickerNavigationController alloc] init];
[_addressBookController setDelegate:self];
[_addressBookController setPeoplePickerDelegate:self];
[self.view addSubview:_addressBookController.view];

我的问题是我想将 ABPeople 控制器统一到我的应用程序 bgcolor 和 tint,但实际上我只能通过以下方法更改导航控制器的标题

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated

有人可以帮我改变所有的颜色和色调吗?

谢谢指教

4

1 回答 1

0

您可以使用方法 (iOS > 5)更改ABPeoplePickerNavigationController的样式。appearanceWhenContainedIn请记住在加载视图控制器之前进行自定义。

这里有一个例子:

[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setBarTintColor:[UIColor yourColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor yourColor]];
[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor yourColor], NSFontAttributeName : [UIFont yourFont]}]; //navigation bar title
[[UISearchBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setBarTintColor:[UIColor yourColor]];
[[UITableView appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setSectionIndexColor:[UIColor yourColor]];
[[UITableViewHeaderFooterView appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:yourColor];

如果您想要一个可以更改哪些属性的完整列表,您可以查看这个问题:我可以通过 UIAppearance 代理设置哪些属性?

于 2015-07-09T11:32:18.847 回答