TableViewCell 分割线全屏宽

在ios7之后 新增@property (nonatomic) UIEdgeInsets separatorInset;

一般情况下 通过设置inset内边距的值即可改变cell分割线的长度。

(注意:)cell左侧同时缩进了15个像素,要想达到去除的效果,在ios8后需要实现如下两个方法:

e.g:

/**
 *  ios8之后对cell分割线 左侧的处理,实现两个方法
 */
- (void)viewDidLayoutSubviews
{
    if ([_rightTableView respondsToSelector:@selector(setSeparatorInset:)]){
        [_rightTableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([_rightTableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [_rightTableView setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

iOS10后可以修改separator Insert 选项的值改变分割线的宽度

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.NSTimer //暂停if ([timer isValid]) {[timer setFireDate:[N...
    俊月阅读 5,202评论 0 0
  • 前言 在iOS开发中,我们最常使用的UIKit控件之一就是UITableView,默认情况下我们可以通过UITab...
    wty21cn阅读 5,937评论 1 5
  • 历史 iOS7之前,系统默认情况下的tableViewCell之间的分割线是左右两端与屏幕边缘之间是没有空隙的(分...
    聪明的笨白阅读 6,509评论 0 3
  • 便如长岭遇雨一般 归来渐渐 归去缓缓
    曲误周郎阅读 1,580评论 0 0
  • 最近不是聚会吗,大体了解了一下大家工作的情况,发现大家对自己的第一份工作都不是很满意。没有具体的数据表明,只是周边...
    静静diary阅读 906评论 0 0

友情链接更多精彩内容