// 添加
UIButton *add = [UIButton buttonWithType:UIButtonTypeCustom];
add.backgroundColor = [UIColor purpleColor];
add.frame = CGRectMake(0, 0, 30, 30);
[add addTarget:self action:@selector(homeViewAddAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *addItem = [[UIBarButtonItem alloc] initWithCustomView:add];
// 搜索
UIButton *search = [UIButton buttonWithType:UIButtonTypeCustom];
search.backgroundColor = [UIColor purpleColor];
search.frame = CGRectMake(0, 0, 30, 30);
[search addTarget:self action:@selector(homeViewSearchAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithCustomView:search];
/**
* 数组的添加顺序是从右向左的 (意思是 加入顺序是相反的)
*/
NSArray *buttons = @[searchItem, addItem];
self.navigationItem.rightBarButtonItems = buttons;