UICollectionViewCell阴影与装饰视图不一致

时间:2018-12-10 22:30:15

标签: ios swift uicollectionview shadow uicollectionviewlayout

我在UICollectionView中使用IGListKit。现在,CollectionView非常简单,因为每个节只有一个单元格。该单元格包含一个内部水平UICollectionView作为图像幻灯片。

由于我需要在整个部分进行阴影处理,因此我正在使用Decoration Views,并为其应用边框阴影:layer.shadowPath

我注意到有些奇怪,阴影的不透明度在当前幻灯片显示的图片上发生了变化。如果图片(或图片的一部分)很亮,则可以看到阴影的不透明度发生了变化。

我不知道这是我可以修复的东西。

您可以清楚地看到,如果我在滑动幻灯片中的图片时截取屏幕截图,则顶部的阴影一侧会变暗。

enter image description here

装饰视图代码:

class FeedItemBackgroundShadowView: UICollectionReusableView {

    // MARK: Initialization

    ... Constructors calling setup

    // MARK: Setup

    override func layoutSubviews() {
        super.layoutSubviews()
        self.layer.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: Constants.cornerRadius).cgPath
    }

    func setup() {
        self.layer.cornerRadius = 12.0
        self.layer.backgroundColor = UIColor.white.cgColor
        self.layer.shadowColor = UIColor.black.cgColor
        self.layer.shadowOffset = CGSize(width: 0.0, height: 2.5)
        self.layer.shadowRadius = 12.0
        self.layer.shadowOpacity = 0.35
}

剩下的代码是一个简单的UICollectionViewCells,其中嵌入了UICollectionView

1 个答案:

答案 0 :(得分:1)

您确定这不是错觉吗?

enter image description here

相关问题