tableView 取消 cell 默认下划线样式 您所在的位置:网站首页 ios下划线 tableView 取消 cell 默认下划线样式

tableView 取消 cell 默认下划线样式

2023-07-30 00:14| 来源: 网络整理| 查看: 265

tableView 无数据的情况下会配置一个默认暂无数据的样式,但 tableView 实例化后会渲染出很多行 cell 的线条,此时看着很不美观,配置如下 code 即可消除 cell 的下横线,需要实例化的时候对 tableView 的数据源进行判空,若有数据的情况下想要保留该下划线则需要不将该属性设置为 none。

if (kArrayIsEmpty(dataSource)) { tabView.backgroundColor = [UIColor clearColor]; tabView.separatorStyle = UITableViewCellSeparatorStyleNone; // 取消默认 cell 下划线样式 UIView *bgView = [[UIView alloc] init]; bgView.frame = tabView.bounds; UIImageView *bgImgView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"imgNoData"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; NSUInteger bgViewWidth = CGRectGetWidth(bgView.frame); NSUInteger bgViewHeight = CGRectGetHeight(bgView.frame); NSUInteger bgImgHeight = (bgViewWidth / 6) * 4 / 2; bgImgView.frame = CGRectMake(bgViewWidth / 6, bgViewHeight / 2 - bgImgHeight / 2, (bgViewWidth / 6) * 4, bgImgHeight); [bgView addSubview:bgImgView]; tabView.backgroundView = bgView; } else { tabView.backgroundColor = [UIColor generateDynamicColor:[UIColor whiteColor] darkColor:[UIColor blackColor]]; tabView.delegate = self; tabView.dataSource = self; [tabView registerClass:[InvoiceCell class] forCellReuseIdentifier:CellIdentifierInvoiceRecordsList]; }

以上便是此次分享的全部内容,希望能对大家有所帮助!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有