0
此代码在UITableView
的顶部和底部创建边距。我如何修改它以做到这一点,但在每个人之间UITableViewCell
?如何在UITableViewCells之间应用此页眉/页脚边距?
// set header height
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 10;
}
// set header colour
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] init];
headerView.backgroundColor = [UIColor lightGrayColor];
return headerView;
}
// set footer height
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 10;
}
// set footer colour
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] init];
headerView.backgroundColor = [UIColor lightGrayColor];
return headerView;
}
如果成功的话,我还希望能够如有可能添加类似于左,右页边距。
每个单元格的部分可能是您正在寻找的部分。对于左/右边距:自定义单元格可以做到这一点。 – Larme
我将如何修改该代码?我在这个方向上的尝试迄今都不成功...... – Sebastian
你有一个返回行数的方法,另一个返回分节数。反转这些数字,并修改cellForRowAtIndexPath。 – Larme