【发布时间】:2019-05-18 02:55:37
【问题描述】:
如何自定义 tableView 单元格,使其底部有一个渐变阴影,类似于 Health App 中的橙色 tableView 单元格。
我想让它尽可能接近这个。
这是我目前拥有的,我使用白色边框添加了单元格之间的分隔,并为角落添加了 8 的半径。
我可以添加什么来制作渐变?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier: String = "stockCell"
let myCell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
myCell.textLabel?.textAlignment = .center
myCell.textLabel?.font = .boldSystemFont(ofSize: 18)
myCell.textLabel?.textColor = UIColor.white
myCell.layer.backgroundColor = UIColor(red:0.86, green:0.25, blue:0.25, alpha:1.0).cgColor
let item: StockModel = feedItems[indexPath.row] as! StockModel
myCell.layer.cornerRadius = 8.0
myCell.layer.masksToBounds = true
myCell.layer.borderColor = UIColor.white.cgColor
myCell.layer.borderWidth = 5.0
myCell.layer.cornerRadius = 20
myCell.clipsToBounds = true
}
【问题讨论】:
标签: ios swift uitableview gradient