【问题标题】:How can I make my UICollectionViewCell Shadow bleed through to my main View?如何让我的 UICollectionViewCell 阴影渗入我的主视图?
【发布时间】:2020-02-20 03:06:47
【问题描述】:

我目前在 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

【问题讨论】:

  • 确保您的 tableView 单元格高度等于或大于您的collectionView cell height + your shadow radius。

标签: ios swift uitableview uicollectionview uikit


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-18
    • 1970-01-01
    • 2021-04-14
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    相关资源
    最近更新 更多