【问题标题】:Add shadow to the collectionViewCell [duplicate]向 collectionViewCell 添加阴影 [重复]
【发布时间】:2018-05-24 18:26:09
【问题描述】:

我想像这样为我的collectionViewItem 开发阴影:

我怎样才能做到这一点? 我正在使用UICollectionView

【问题讨论】:

  • 嗨@matt,你建议的重复答案对我不起作用。
  • 嗨@Tanveer!关键是您的问题非常广泛,并且如何向集合视图单元格添加圆形边框和阴影的整个问题已经在这里深入处理过很多次,因此搜索会出现所有您需要的信息。因此,问题的新重复确实不需要发生。

标签: ios swift xcode user-interface uicollectionview


【解决方案1】:
  • 向您的单元格添加一个视图,左、右、上和下约束为 5(或其他)。

  • 添加将所有单元格内容放在该视图中

  • 为视图创建一个出口

  • 风格:

    yourView.layer.borderColor = UIColor(red:0, green:0, blue:0, alpha:0.5).cgColor
    yourView.layer.shadowOffset = CGSize(width: 0, height: 2)
    yourView.layer.shadowColor = UIColor(red:0, green:0, blue:0, alpha:0.5).cgColor
    yourView.layer.shadowOpacity = 0.5
    yourView.layer.shadowRadius = 3
    
  • 如果你想要圆角:

    yourView.layer.cornerRadius = 8
    

【讨论】:

  • 这也有帮助。谢谢
猜你喜欢
  • 2013-12-25
  • 2022-01-24
  • 2021-07-13
  • 2012-02-19
  • 2015-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多