首页 > 解决方案 > 如何让我的 UICollectionViewCell 阴影渗入我的主视图?

问题描述

我目前在 UITableViewCell 中有一个 UICollectionView(水平)。我想为集合视图单元格添加一个阴影,但是由于 tableview 单元格的高度,阴影被切断了。有什么办法可以让影子流血吗?

(可能很难从这张图片中分辨出来,但它的顶部和底部都被切断了)

我有一个剪辑到 CVCell 边界的“背景”,

background.backgroundColor = .white
background.layer.cornerRadius = 8
background.layer.shadowColor = UIColor.black.cgColor
background.layer.shadowRadius = 7
background.layer.shadowOpacity = 0.3
background.layer.shadowOffset = CGSize(width: 0, height: 3)
background.layer.masksToBounds = true
background.clipsToBounds = false

在我的 UITableViewCell (不是具有背景的单元格)中,我设置了

cell.layer.masksToBounds = false
cell.clipsToBounds = true

标签: iosswiftuitableviewuicollectionviewuikit

解决方案


请检查collectionView单元格的顶部和按钮约束设置。


推荐阅读