【发布时间】:2018-01-20 16:17:07
【问题描述】:
我的 TableViewController 上有一个自定义的 TableViewCell。 该单元格有一个 UIView,它变成了一个渐变,在底部显示黑色,在 UIView 顶部显示清晰(透明)的颜色。
应用加载时看起来不错,但是当我滚动时,渐变变得越来越黑,并且“淡化”本身变得更小并且更接近 UIView 的顶部。
我不知道如何让它保持最初加载应用时的状态。
这是我的代码:
let gradient = CAGradientLayer()
gradient.frame = cell.gradientView.bounds
let colour:UIColor = .black
gradient.colors = [colour.withAlphaComponent(0.0).cgColor,colour.cgColor]
cell.gradientView.layer.insertSublayer(gradient, at: 0)
【问题讨论】:
标签: ios swift uitableview uiview