CustomSeperatorInsetTableView
解决难以统一配置UITableView
的seperatorInset
问题
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
,右侧填入你希望的insetLeft
和insetRight
值,不填默认为0
install
add this to Podfile
pod 'CustomSeperatorInsetTableView', '~> 0.0.2'