gpt4 book ai didi

swift - 无法调用非函数类型 [UIColor] 的值

转载 作者:行者123 更新时间:2023-11-28 12:52:20 24 4
gpt4 key购买 nike

<分区>

我已将此代码写入 Swift,但最后一行代码返回此错误消息:

Cannot call value of non-function type '[UIColor]'

import Foundation
import UIKit

struct Colores {
let colores = [UIColor(red: 210/255.0, green: 90/255.0, blue: 45/255.0, alpha: 1),
UIColor(red: 40/255.0, green: 170/255.0, blue: 45/255.0, alpha: 1),
UIColor(red: 3/255.0, green: 180/255.0, blue: 90/255.0, alpha: 1),
UIColor(red: 210/255.0, green: 190/255.0, blue: 5/255.0, alpha: 1),
UIColor(red: 120/255.0, green: 120/255.0, blue: 50/255.0, alpha: 1),
UIColor(red: 130/255.0, green: 80/255.0, blue: 90/255.0, alpha: 1),
UIColor(red: 130/255.0, green: 130/255.0, blue: 130/255.0, alpha: 1),
UIColor(red: 3/255.0, green: 50/255.0, blue: 90/255.0, alpha: 1)]


func regresaColorAleatorio() -> UIColor{
let posicion = Int(arc4random()) % colores.count
return colores(posicion)
}
}

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