如何去除第一个电池顶部分隔器和最后一个电池底部分隔器 [英] How to remove first cell top separator and last cell bottom separator

查看:28
本文介绍了如何去除第一个电池顶部分隔器和最后一个电池底部分隔器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除特定部分中第一个单元格的顶部边框和特定部分中最后一个单元格的底部边框.

I need to remove top border form first cell in a particular section and bottom border form last cell in a particular section.

我在 google 上搜索了从 tableView 中完全隐藏分隔符的解决方案,但我想避免它.

I googled solution for complete hiding separators from tableView, but I'd like to avoid it.

此外,当您收到事件时,当单元格将显示以使用分隔符插入时,我也找到了解决方案.它适用于两个单元格之间的中间分隔符,但不适用于页眉/页脚和单元格之间的分隔符.

Also I've found solution when you get event when the cell will be displaying to play with separator insets. It works for middle separators, between two cells, but not for separator between header/footer and cell.

另外,我试图在标题中查看子图层,但由于此视图是我自己创建的,因此我没有找到分隔符视图.

Plus I've tried to see sublayers in the header, but since this view is created by myself, I didn't found there separator view.

也许我应该在标题中使用图层?请给我一个线索.

May be I should work with layers inside header? Please, give me a clue.

推荐答案

下面的代码帮助我删除 UITableView 中最后一行的分隔符.

Below code helps me to remove the separator from last row in a UITableView.

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        if indexPath.row == tableView.numberOfRows(inSection: indexPath.section) {
            cell.separatorInset.left = cell.bounds.size.width
        }
    }

这篇关于如何去除第一个电池顶部分隔器和最后一个电池底部分隔器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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