自定义导航右边多个按钮

- (void)initRightBtnItems{
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 44.0f)];
    view.backgroundColor = [UIColor clearColor];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:@"BTN1" forState:UIControlStateNormal];
    [button setBackgroundColor:[UIColor clearColor]];
    button.frame = CGRectMake(0, 9, 25, 25);
    [button addTarget:self action:@selector(stopDownloadAll) forControlEvents:UIControlEventTouchUpInside];
    [button setImage:[UIImage imageNamed:@"btn_shezhi_nor.png"] forState:UIControlStateNormal];

    [view addSubview:button];
    
    
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
//    [button2 setTitle:@"BTN2" forState:UIControlStateNormal];
    [button2 setBackgroundColor:[UIColor clearColor]];
    button2.frame = CGRectMake(28, 9, 25, 25);
     [button2 addTarget:self action:@selector(stopDownloadAll) forControlEvents:UIControlEventTouchUpInside];
    [button2 setImage:[UIImage imageNamed:@"btn_saishi_nor.png"] forState:UIControlStateNormal];
    [view addSubview:button2];

    
    UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
//    [button3 setTitle:@"BTN3" forState:UIControlStateNormal];
    [button3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button3 setBackgroundColor:[UIColor clearColor]];
    button3.frame = CGRectMake(55, 9, 25, 25);
    [button3 addTarget:self action:@selector(stopDownloadAll) forControlEvents:UIControlEventTouchUpInside];
     [button3 setImage:[UIImage imageNamed:@"btn_gerenzhongxin_nor.png"] forState:UIControlStateNormal];
    [view addSubview:button3];
    

    
    UIButton *button4 = [UIButton buttonWithType:UIButtonTypeCustom];
//    [button4 setTitle:@"BTN4" forState:UIControlStateNormal];
    [button4 setBackgroundColor:[UIColor clearColor]];
    button4.frame = CGRectMake(83, 9, 25, 25);
    [button4 addTarget:self action:@selector(stopDownloadAll) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button4];
    
    [button4 setImage:[UIImage imageNamed:@"btn_faxian_nor.png"] forState:UIControlStateNormal];
    [button4 setBackgroundColor:[UIColor clearColor]];
   
    
    UIButton *button5 = [UIButton buttonWithType:UIButtonTypeCustom];
//    [button5 setTitle:@"BTN4" forState:UIControlStateNormal];
//    [button5 setBackgroundColor:[UIColor brownColor]];
    button5.frame = CGRectMake(102, 9, 25, 25);
    [button5 addTarget:self action:@selector(stopDownloadAll) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button5];


    
    UIBarButtonItem *cusView = [[UIBarButtonItem alloc]initWithCustomView:view];
    [cusView setBackButtonBackgroundImage:[UIImage imageNamed:@"btn_faxian_nor.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    
//    UIBarButtonItem *cusView2 = [[UIBarButtonItem alloc]initWithCustomView:button2];
//    [cusView setBackButtonBackgroundImage:[UIImage imageNamed:@"btn_faxian_nor.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
//    
//     UIBarButtonItem *cusView3 = [[UIBarButtonItem alloc]initWithCustomView:button3];
//     UIBarButtonItem *cusView4 = [[UIBarButtonItem alloc]initWithCustomView:button4];
//    UIBarButtonItem *cusView5 = [[UIBarButtonItem alloc]initWithCustomView:button5];

//    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:cusView,cusView2,cusView3, cusView4,cusView5,nil]];
    
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:cusView,nil]];

    
   
    
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值