在一个 UITableViewCell 上隐藏分隔线 [英] Hide separator line on one UITableViewCell

查看:40
本文介绍了在一个 UITableViewCell 上隐藏分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自定义一个 UITableView.我想隐藏 last 单元格上的分隔线……我可以这样做吗?

I'm customizing a UITableView. I want to hide the line separating on the last cell ... can i do this?

我知道我可以做 tableView.separatorStyle = UITableViewCellStyle.None 但这会影响 all tableView 的单元格.我希望它只影响我的最后一个单元格.

I know I can do tableView.separatorStyle = UITableViewCellStyle.None but that would affect all the cells of the tableView. I want it to only affect my last cell.

推荐答案

UITableViewDataSource cellForRowAtIndexPath方法中

斯威夫特:

if indexPath.row == {your row number} {
    cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: .greatestFiniteMagnitude)
}

或:

cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, UIScreen.main.bounds.width)

对于默认保证金:

cell.separatorInset = UIEdgeInsetsMake(0, tCell.layoutMargins.left, 0, 0)

端到端显示分隔符

cell.separatorInset = .zero

目标-C:

if (indexPath.row == {your row number}) {
    cell.separatorInset = UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, CGFLOAT_MAX);
}

这篇关于在一个 UITableViewCell 上隐藏分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆