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