iOS tableviewcell 分割线不完整
2016-09-07 本文已影响90人
seky
在使用tableview的时候 发现cell之间的分割线与屏幕右边有一段小小的距离,如图:

-
而如果想要让分割线从头开始,可以使用下面的方法,在tableview初始化的时候用下面这个方法
-
代码如下:
+ (void)lineBeginWith:(UITableView *)tableview{ if (IOS_VERSION >= 8.0){ if ([tableview respondsToSelector:@selector(setSeparatorInset:)]){ [tableview setSeparatorInset:UIEdgeInsetsZero]; } if ([tableview respondsToSelector:@selector(setLayoutMargins:)]) { [tableview setLayoutMargins:UIEdgeInsetsZero]; } } }
-
之后在对cell用下面这个方法
-
代码如下:
+ (void)lineBeginWithCell:(UITableViewCell *)cell{ if (IOS_VERSION >= 8.0){ if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cell setSeparatorInset:UIEdgeInsetsZero]; } if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { [cell setLayoutMargins:UIEdgeInsetsZero]; } } }