The code is as follows |
Copy Code |
1. The Custom click button toggles the different Tableviewcell, the effect as shown in the picture
|
The code is as follows |
Copy Code |
2.1 Import Hqsliderview
|
Copy Hqsliderview to project. png
The code is as follows |
Copy Code |
2.2 Viewdidload Method inside
|
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self setupTopSliderView];
[self setupTableView];
}
The code is as follows |
Copy Code |
2.3 Create Upper Sliderview
|
#pragma mark - 创建上部SliderView
- (void)setupTopSliderView
{
HQSliderView *sliderView = [[HQSliderView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT, SCREEN_WIDTH, SLIDER_HEIGHT)];
sliderView.titleArr = @[@"全部", @"待付款", @"已付款", @"退款"];
sliderView.delegate = self;
[self.view addSubview:sliderView];
}
The code is as follows |
Copy Code |
2.4 Creating TableView
|
#pragma mark - 创建TableView
- (void)setupTableView
{
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT + SLIDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT)];
tableView.dataSource = self;
[self.view addSubview:tableView];
self.tableView = tableView;
}
code is as follows |
copy code |
2.5 implementing TableView Data source Method
|
#pragma mark-uitableviewdatasource-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (NSInteger
) Section {if (Self.menutag = 0) {return 3;
else if (Self.menutag = = 1) {return 6;
else if (Self.menutag = = 2) {return 9;
else {return 12; }-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) IndexPath {HQTableV
Iewcell *cell = [Hqtableviewcell Tableviewcellwithtableview:tableview];
if (Self.menutag = = 0) {Cell.textLabel.text = [nsstring stringwithformat:@ "All---%ld rows", Indexpath.row];
else if (Self.menutag = 1) {cell.textLabel.text = [nsstring stringwithformat:@ "pending Payment---%ld rows", Indexpath.row]; else if (Self.menutag = 2) {cell.textLabel.text = [nsstring stringwithformat:@ ' Paid---%ld rows ', Indexpath.
Row];
else {cell.textLabel.text = [nsstring stringwithformat:@ "Refund---%ld rows", Indexpath.row];
} return cell; }
The code is as follows |
Copy Code |
2.6 Proxy method to implement Hqsliderview
|
#pragma mark - HQSliderViewDelegate
- (void)sliderView:(HQSliderView *)sliderView didClickMenuButton:(UIButton *)button
{
self.menuTag = button.tag;
[self.tableView reloadData];
}