首页 > 解决方案 > UITableViewCell Layer Shadow Overlap Cell 上面

问题描述

一切都在标题中。

我有一个带有单元格的 UITableView。单元格有一个阴影(self.layer.shadow ...)。

问题是一个单元格的阴影上面的单元格重叠。我怎样才能防止这种行为?

在此处输入图像描述

这是我单元格中的代码:

    self.layer.shadowColor = UIColor.gray.cgColor
    self.layer.shadowOffset = .zero
    self.layer.shadowOpacity = 0.15
    self.layer.shadowRadius = 10
    self.layer.cornerRadius = 8
    backgroundColor = .white

标签: iosuitableviewcellcalayershadow

解决方案


使用此代码添加阴影:-

self.layer.masksToBounds = false
self.layer.shadowOffset = CGSize(width: -1, height: 1)
self.layer.shadowOpacity = 0.2
self.layer.cornerRadius = 8

推荐阅读