Swift 版本的 UITableViewCell 分割线
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// ...
cell.setSeparatorLineStyle([.display(.show(l: 0, r: 20)), .color(UIColor.red), .height(0.5)])
// 或者颜色使用字符串形式
// .color("#3125FF")
}
- 如果
UITableView
设置了Style
为grouped
,仍然会有上下两条线,需要设置
tableView.separatorStyle = .none
MWTableViewCellSeparatorLineSwift 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:
pod 'MWTableViewCellSeparatorLineSwift'
LiY, [email protected]
MWTableViewCellSeparatorLineSwift 在 MIT 许可下可用。更多信息请查看 LICENSE 文件。