UITableViewCell最后一行分割线位置设置

一、手动设置

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==self.dataArray.count-1) {
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    }

}

/**
 *  布局视图
 */
-(void)viewDidLayoutSubviews
{
    if ([self.myTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.myTableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    }
    
    if ([self.myTableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.myTableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
}

二、使用第三方ESSeparatorInset分类

UITableView 隐藏最后一条分割线-->footerView高度0.1)

ESSeparatorInset分类一行代码搞定

UIView

UIViewController+ESSeparatorInset.h
UIViewController+ESSeparatorInset.m

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,263评论 4 61
  • 老师要求:看《天空小熊 第一次探险》1~6页 ,并提出几个问题, 然后跟孩子一起寻找答案。 先记录一...
    方敏_ecdb阅读 444评论 0 0
  • 完成图
    baimu阅读 229评论 1 1
  • 六十二 落叶潇潇 湖蟹肥美 桂花酿圆子忘不了的家乡味 六十三 家乡 家乡 只有母亲在稻田里遥望 遥望我们奔波四海...
    萧路遥阅读 160评论 3 1
  • 春节的时候,父亲二十多年前的学生来家里看望他,开着奥迪车,拿着礼品酒,说要请父亲去参加以前的小学聚会,地点就在...
    明晨Demain阅读 336评论 0 0