// // RAHomeViewController+HomeTableDelegate.m // Apex And Drivers // // Created by Jack on 2018/6/1. // Copyright © 2018年 USAI. All rights reserved. // #import "RAHomeViewController+HomeTableDelegate.h" #import "RAHomeOrderModel.h" @implementation RAHomeViewController (HomeTableDelegate) #pragma mark - TableView Delegate - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 120.0f; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 44.0f)]; header.backgroundColor = [UIColor lightGrayColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 11, CGRectGetWidth(tableView.bounds) - 100, 22)]; [header addSubview:label]; label.text = [self titleForSection:section]; UIButton *expandBtn = [UIButton buttonWithType:UIButtonTypeSystem]; expandBtn.frame = CGRectMake(CGRectGetWidth(tableView.bounds) - 90, 11, 80, 22); [expandBtn setTitle:@"More" forState:UIControlStateNormal]; // [expandBtn setTitleColor:expandBtn.tintColor forState:UIControlStateNormal]; // [expandBtn setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateHighlighted]; expandBtn.tag = section; [expandBtn addTarget:self action:@selector(sectionExpandSwithBtnClick:) forControlEvents:UIControlEventTouchUpInside]; [header addSubview:expandBtn]; expandBtn.hidden = ![self hasMoreOrderForSection:section]; return header; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 44.f; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { RAHomeOrderModel *order = [self orderModelForIndexPath:indexPath]; self.currentOrderID = order.orderID; [self pushDetailViewControllerForModel:order]; } #pragma mark - Action - (void)sectionExpandSwithBtnClick:(UIButton *)sender { [self showMoreOrderForSection:sender.tag]; } @end