/** 状态栏4个按钮 */
- (UIView *)topSegmenteView{
if (!_topSegmenteView) {
_topSegmenteView = [[UIView alloc] init];
_topSegmenteView.backgroundColor = UIColor.whiteColor;
CGFloat centerPoint_x = 0.0f;
for (int i = 0; i < 4; i++) {
UIButton *segmenteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
segmenteBtn.tag = 10001+i;
[segmenteBtn addTarget:self action:@selector(segmentBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
segmenteBtn.frame = CGRectMake((kScreenWidth)/4*i, 0, (kScreenWidth)/4, 50);
[segmenteBtn setTitle:i == 0 ? @"全部" : (i == 1 ? @"待发货" : (i == 2 ? @"待收货" : @"已完成")) forState:(UIControlStateNormal)];
[segmenteBtn setTitleColor:[UIColor getClassTitleColor] forState:(UIControlStateNormal)];
if (i == 0) {
centerPoint_x = segmenteBtn.center.x;
[segmenteBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
}
[_topSegmenteView addSubview:segmenteBtn];
}
self.showLineView = [[UIView alloc]initWithFrame:CGRectMake(0, 50-3, (kScreenWidth-100)/4, 3)];
self.showLineView.centerX = centerPoint_x ? centerPoint_x : (kScreenWidth-20)/6;
_showLineView.backgroundColor = [UIColor getSXOrangeColor];
[_topSegmenteView addSubview:_showLineView];
}
return _topSegmenteView;
}
pragma mark - **************** Event
/** 状态栏点击事件 */
- (void)segmentBtnAction:(UIButton *)sender {
/** UI*/
self.showLineView.centerX = sender.centerX;
///其他都设置灰色
for (int i = 10001; i < 10005; i++) {
UIButton *segmenteBtn = [self.topSegmenteView viewWithTag:i];
[segmenteBtn setTitleColor: [UIColor getClassTitleColor] forState:(UIControlStateNormal)];
}
///选中的设置黑色
[sender setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
/** 状态 (-1=全部 0=代发货,1=已发货,2=已完成,3=已关闭)*/
switch (sender.tag) {
case 10001:
self.requestTypeNum = -1;
NSLog(@"10001");
self.scrollView.contentOffset = CGPointMake(0, 0);
[self.allListTB.mj_header beginRefreshing];
break;
case 10002:
self.requestTypeNum = 0;
NSLog(@"10002");
self.scrollView.contentOffset = CGPointMake(kScreenWidth, 0);
[self.waitSendListTB.mj_header beginRefreshing];
break;
case 10003:
self.requestTypeNum = 1;
NSLog(@"10003");
self.scrollView.contentOffset = CGPointMake(kScreenWidth*2, 0);
[self.waitReciveListTB.mj_header beginRefreshing];
break;
case 10004:
self.requestTypeNum = 2;
NSLog(@"10004");
self.scrollView.contentOffset = CGPointMake(kScreenWidth*3, 0);
[self.wellDoneListTB.mj_header beginRefreshing];
break;
default:
break;
}
}
网友评论