博客> 导航栏 自定义某一侧多个按钮
导航栏 自定义某一侧多个按钮
2019-12-11 08:19 评论:0 阅读:948 wangwei1
ios navigationItem
self.secondRightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
self.secondRightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
[self.secondRightBtn setImage:[UIImage imageNamed:@"membermore"]  forState:UIControlStateNormal];
[self.secondRightBtn setImage:[UIImage imageNamed:@"membermore_select"]  forState:UIControlStateSelected];
[self.secondRightBtn addTarget:self action:@selector(secondToClick:) forControlEvents:UIControlEventTouchUpInside];

self.firstRightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
self.firstRightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
[self.firstRightBtn setImage:[UIImage imageNamed:@"firstwrite_normal"]  forState:UIControlStateNormal];
[self.firstRightBtn setImage:[UIImage imageNamed:@"firstwrite_select"]  forState:UIControlStateSelected];
[self.firstRightBtn addTarget:self action:@selector(firstToClick:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *firstItem = [[UIBarButtonItem alloc] initWithCustomView:self.firstRightBtn];
UIBarButtonItem *secondItem = [[UIBarButtonItem alloc] initWithCustomView:self.secondRightBtn];

self.navigationItem.rightBarButtonItems = @[firstItem,secondItem];
收藏
0
sina weixin mail 回到顶部