【问题标题】:specify the separator line width of the table view [duplicate]指定表格视图的分隔线宽度[重复]
【发布时间】:2016-03-07 16:26:23
【问题描述】:

tableview中默认的分隔线不占用整个单元格的宽度。如何指定行分隔符宽度来占用tableview的整个宽度?

这是默认的外观:

【问题讨论】:

标签: ios uitableview tableviewcell


【解决方案1】:

从单元格中删除所有边距设置。尝试将所有这些添加到

中的单元格中
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    // Remove insets in UITableViewCell separator

// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    cell.separatorInset = UIEdgeInsetsZero;
}

// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
    cell.preservesSuperviewLayoutMargins = NO;
}

// Explictly set cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    cell.layoutMargins = UIEdgeInsetsZero;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-10
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    • 1970-01-01
    • 2015-07-21
    • 2012-12-18
    相关资源
    最近更新 更多