- (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]];
}
自定义导航右边多个按钮
最新推荐文章于 2024-06-29 04:00:49 发布