/CustomSeperatorInsetTableView

Figure out Customing SeperatorInset of UITableView in iOS7+ just for One Properties

Primary LanguageRubyMIT LicenseMIT

CustomSeperatorInsetTableView

解决难以统一配置UITableViewseperatorInset问题

before

以往可能需要在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];
    }
}

now

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

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

install

add this to Podfile

pod 'CustomSeperatorInsetTableView', '~> 0.0.2'