【问题标题】:change tint and background colors of a ABPeoplePickerNavigationController embedded in a tab bar view controller更改嵌入在标签栏视图控制器中的 ABPeoplePickerNavigationController 的色调和背景颜色
【发布时间】: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

可以帮我更改所有颜色和色调吗?

感谢您的建议

【问题讨论】:

    标签: ios objective-c abpeoplepickerview


    【解决方案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?

    【讨论】:

      猜你喜欢
      • 2016-01-14
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-08
      相关资源
      最近更新 更多