ios - 如何区分 TableView 中两个 TableView 单元格之间的差距?

标签 ios swift

<分区>

我试过这段代码,但它对我不起作用:

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)

我希望输出是这样的:

enter image description here

最佳答案

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

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

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

相关文章:

javascript - 在不使用 jQuery 的情况下获取移动设备(尤其是 iPhone)上的窗口高度

ios - 如何在 XCode 6 中对齐标签垂直居中

ios - 有时 ios MKMapView 在转到其他屏幕并返回到 MapScreen 时崩溃

swift - Audiokit pod 出现重复符号

ios - 如何从 Date() 中提取今天、昨天并使其像工作日和月份一样本地化?

ios - 弹出错误位置

swift - 为什么消息不显示?

ios - PKAddPassButton 不适用于 iOS 9

swift - tvOS 中的 UIScrollView

iphone - 如何自定义导航栏的文字颜色