tableViewCell的分割线默认会留出一段空白,可以通过setSeparatorInset来解决问题,但在ios8里这个方法无效,解决方法如下:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[tableView setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
本文介绍了解决iOS中TableViewCell分割线默认留白的问题。通过调整布局边距和分割线内边距,可在iOS8及后续版本中实现无缝显示。
1179

被折叠的 条评论
为什么被折叠?



