【问题标题】:Excessive drop shadow in UITableViewUITableView 中的阴影过多
【发布时间】:2019-05-26 05:53:03
【问题描述】:

这是截图:

如果您查看顶部单元格,则会出现过度的阴影,而底部的单元格具有预期的阴影效果。多余的消失并在将其滚动出屏幕然后返回后恢复正常。我不知道这是怎么回事。

这是我在 tableview 单元格类中的投影代码:

override func layoutSubviews() {
    super.layoutSubviews()
    let shadowPath = UIBezierPath(rect: containerView.bounds)
    containerView.layer.masksToBounds = false
    containerView.layer.shadowColor = UIColor.black.cgColor
    containerView.layer.shadowOffset = CGSize(width: 0, height: 0.1)
    containerView.layer.shadowOpacity = 0.2
    containerView.layer.shadowPath = shadowPath.cgPath
  }

请帮忙,谢谢!

【问题讨论】:

  • 你能给我们看看这方面的图片吗?
  • 图片在上面。

标签: ios swift xcode uitableview


【解决方案1】:

我想通了。基本上,我使用 containerView.bounds 作为阴影路径,但图层被绘制得太大,因为单元格开始时很大,然后根据设备缩小。解决方案是使用常量。预测高度和宽度并使用 CGRect。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多