CustomSeperatorInsetTableView 0.0.2

CustomSeperatorInsetTableView 0.0.2

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2016年4月

Ron 维护。



  • BOOLRon

解决难以统一配置 UITableViewseparatorInset 的问题

之前

过去可能需要在这些 UIViewController 里写:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    // Remove seperator inset
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }

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

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

现在

现在只需继承 CustomSeperatorInsetTableView,将代码配置为 mySeparatorInset 为你希望的值,默认值为 UIEdgeInsetsZero

另外你也可以在 IB 中修改 UITableView 的 Class 为 CustomSeperatorInsetTableView,右侧填入你希望的 separatorLeftseparatorRight 值,不填默认为 0