我想在图 TableView 中设置多种背景颜色。图 TableView 的背景可以设置单一颜色,但无法设置多种颜色。
按百分比希望添加背景颜色 0% 到 20% - 红色,21% 到 60% - 白色,61% 到 100% 为绿色
最佳答案
我认为您正在寻找 CAGradientLayer,它可能对您有帮助。
let gradient = CAGradientLayer()
gradient.colors = [UIColor.red.cgColor, UIColor.green.cgColor]
gradient.locations = [0.0, 1.0]
let view = UIView()
view.layer.insertSublayer(gradient, at: 0)
View 是您要应用颜色的位置。
如果您想了解更多详细信息:https://developer.apple.com/documentation/quartzcore/cagradientlayer
关于ios - 如何在iOS Chart Graph Framework中设置多种背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60113437/