вы можете создать пользовательскую ячейку и добавить строку при необходимости
class CustomCell: UITableViewCell {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy public var line : UIView = {
let view = UIView.init(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 0.5))
view.backgroundColor = .gray
return view
}()
lazy public var stackLine : UIStackView = {
let stackLine = UIStackView.init(arrangedSubviews: [self.line,self.line,self.line,self.line,self.line]) // line as you need
stackLine.axis = .vertical
stackLine.distribution = .fill
stackLine.spacing = 1
stackLine.alignment = .fill
return stackLine
}()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.addSubview(stackLine)
NSLayoutConstraint.activate([
stackLine.leadingAnchor .constraint(equalTo: self.contentView.leadingAnchor, constant: 0),
stackLine.trailingAnchor .constraint(equalTo: self.contentView.trailingAnchor, constant: 0),
stackLine.bottomAnchor .constraint(equalTo: self.contentView.bottomAnchor, constant: 0),
stackLine.heightAnchor.constraint(equalToConstant: 5 * 0.5 + 1 * 4 ) // say 5 line * height of line + line space * number ofline -1
]
)
}
}