-(void)customrightNav
{
NSMutableArray *items = [NSMutableArray array];
NSArray *titleArr = @[@"删除",@"保存",@"分享"];
for (NSInteger i = 0; i<titleArr.count; i++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(10, 7, 30, 30);
button.tag = 600+i;
[button setTitle:titleArr[i] forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:12.0f];
[button addTarget:self action:@selector(clickRightBtn:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
[items addObject:item];
}
self.navigationItem.rightBarButtonItems = items;
}
-(void)clickRightBtn:(UIButton *)button
{
switch (button.tag) {
case 600://删除
{
}break;
case 601://保存
{
}break;
case 602://分享
{
}break;
}
}
注:排列顺序为 分享、保存、删除