利用tableview的代理方法來(lái)實(shí)現(xiàn)自定義背景色霎冯,非常簡(jiǎn)單的幾句代碼
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 8;//每組間距的高度最好設(shè)置為宏,和下面的view的高度保持一致
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return .001;//貌似這樣設(shè)置效果好點(diǎn)
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 8)];
//自定義顏色
view.backgroundColor = [UIColor cyanColor];
return view;
}
覺(jué)得可以star我吧燃少!????