【问题标题】:How to get differentiating gap between two tableview cells in a tableview? [duplicate]如何区分表格视图中两个表格视图单元格之间的差距? [复制]
【发布时间】:2019-04-27 05:26:02
【问题描述】:

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

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)

我希望输出是这样的:

【问题讨论】:

    标签: ios swift


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2018-07-30
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多