gpt4 book ai didi

ios - 有些 UIColors 是黑色的,而不是它们应该的样子,为什么?

转载 作者:行者123 更新时间:2023-11-28 10:37:01 25 4
gpt4 key购买 nike

<分区>

我正在制作这个应用程序,假设我获得了 rgba 颜色的红色、绿色和蓝色的 CGFloat 值。我使用它们为 tableView 中的单元格赋予颜色。有些工作得很好,但有些是黑色的,而不是它们应该的颜色。它主要是深色,虽然我非常怀疑这与它有什么关系。我不知道为什么会这样。

代码如下:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Bundle.main.loadNibNamed("CustomTableViewCell", owner: self, options: nil)?.first as! CustomTableViewCell
cell.cellColor.backgroundColor = UIColor(red: CGFloat(myClasses[indexPath.row].red), green: CGFloat(myClasses[indexPath.row].green), blue: CGFloat(myClasses[indexPath.row].blue), alpha: 1.0)
cell.cellLabel.text = myClasses[indexPath.row].name
return cell
}

一些例子:

case "Light green":
colorArray = [128/255, 1, 0]
case "Dark green":
colorArray = [76/255, 153/255, 0]
case "Light blue":
colorArray = [0, 1, 1]
case "Dark blue":
colorArray = [51/255, 51/255, 1]
case "Purple":
colorArray = [102/255, 0, 204/255]
case "Yellow":
colorArray = [1, 1, 0]

浅绿色、浅蓝色和黄色作品。深绿色、深蓝色和紫色则不然。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com