【问题标题】:UITableView section shadow [duplicate]UITableView 部分阴影 [重复]
【发布时间】:2016-07-15 17:05:57
【问题描述】:

如何在 UITableViewController 中实现 tableView 部分阴影。

【问题讨论】:

  • 你想把这个阴影写在节头吗?或在整个部分中
  • 不在节标题中。我想要整个部分的阴影。检查上面附加的图像,这些是单独的部分。
  • 找到了实现它的方法。检查this

标签: ios swift uitableview


【解决方案1】:

添加此方法以获取 UITableView 部分的阴影 这个答案在 Swift3 中

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let shadowView = UIView()
    let gradient = CAGradientLayer()
    gradient.frame.size = CGSize(width: tableView.bounds.width, height: 15)

    let stopColor = UIColor.gray.cgColor    
    let startColor = UIColor.white.cgColor    

    gradient.colors = [stopColor, startColor]    
    gradient.locations = [0.0,0.8]

    shadowView.layer.addSublayer(gradient)    

    return shadowView
}

【讨论】:

  • 什么是 myTab??
  • 问题是关于节而不是节页眉或页脚!
猜你喜欢
  • 2012-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多