swift - 使用 CAGradientLayer 渲染按钮
问题描述
当我使用 CAGradientLayer 设置一个按钮时,它没有正确显示。
func setGradientBackground(color_A: UIColor, color_B: UIColor, indexLayer : Int){
let granderLayer = CAGradientLayer()
granderLayer.frame = bounds
granderLayer.colors = [color_A.cgColor, color_B.cgColor]
granderLayer.locations = [0.0, 1.0]
granderLayer.startPoint = CGPoint(x: 1.0, y: 1.0)
granderLayer.endPoint = CGPoint(x: 0.0, y: 0.0)
layer.insertSublayer(granderLayer, at: UInt32(indexLayer))
}
在滚动后的 UITableView 的情况下,这有效
解决方案
您应该检查以下行中的边界值:“granderLayer.frame = bounds”。
推荐阅读
- c# - 如何将序列化的匿名对象转换回对象?
- linux - VM_UFFD_MISSING 的语义是什么?
- r - 如何使用程序 R 将字符串数字(在数据集上)转换为数值?
- google-apps-script - 有没有办法根据谷歌表格中的行标准将文件从谷歌表单提交移动到另一个文件夹中
- colors - 应用 seaborn yticklabels 颜色后,未对齐
- gurobi - Gurobi 中的“模型不可行或无界”——然而,这似乎是不正确的
- javascript - 在 Nuxt.js 中渲染之前如何拥有 auth.loggedIn?
- python-3.x - 使用 ne_chunks 提取全名
- python - 通过 Python 连接器 OKTA 连接到雪花
- unity3d - IndexOutOfRangeException:无法弄清楚为什么索引超出范围