whiteBackgroundLayerView

whiteBackgroundLayerView

This question already has answers here:
How to add spacing between UITableViewCell
(24个答案)
12个月前关闭。
我试过这个代码,但它对我不起作用:
let whiteBackgroundLayerView: UIView = UIView(frame: CGRect(x: 10 , y: 8, width: self.view.frame.size.width - 20, height: 90))
whiteBackgroundLayerView.layer.backgroundColor = CGColor(colorSpace: CGColorSpaceCreateDeviceRGB(), components: [1.0, 1.0, 1.0, 0.8])
whiteBackgroundLayerView.layer.masksToBounds = false
whiteBackgroundLayerView.layer.cornerRadius = 2.0
cell.contentView.addSubview(whiteBackgroundLayerView)
cell.contentView.sendSubviewToBack(whiteBackgroundLayerView)

我希望输出如下:

最佳答案

在自定义单元格中,添加以下代码:

override func layoutSubviews() {
    super.layoutSubviews()
    contentView.frame = UIEdgeInsetsInsetRect(contentView.frame, UIEdgeInsetsMake(10, 10, 10, 10))
}

关于ios - 如何在表 View 中区分两个表 View 单元格之间的间隙? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53466344/

10-12 06:15