更改嵌入在标签栏视图控制器中的 ABPeoplePickerNavigationController 的色调和背景颜色
Posted
技术标签:
【中文标题】更改嵌入在标签栏视图控制器中的 ABPeoplePickerNavigationController 的色调和背景颜色【英文标题】:change tint and background colors of a ABPeoplePickerNavigationController embedded in a tab bar view controller 【发布时间】:2014-08-06 15:23:24 【问题描述】:我有一个标签栏控制器,我想嵌入一个 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
可以帮我更改所有颜色和色调吗?
感谢您的建议
【问题讨论】:
【参考方案1】:您可以使用 appearanceWhenContainedIn
方法 (ios > 5) 更改 ABPeoplePickerNavigationController 的样式。请记住在加载视图控制器之前进行自定义。
这里是一个例子:
[[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];
如果您想了解可以更改哪些属性的完整列表,可以查看以下问题:What properties can I set via an UIAppearance proxy?
【讨论】:
以上是关于更改嵌入在标签栏视图控制器中的 ABPeoplePickerNavigationController 的色调和背景颜色的主要内容,如果未能解决你的问题,请参考以下文章