0
我寫了這個代碼到斯威夫特,但代碼返回此錯誤消息的最後一行:不能調用非功能型的值的UIColor]
不能調用非功能型的價值「[的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)
}
}
嗯,我想那是因爲你嘗試調用'顏色(位置)'這是不是一個函數(如錯誤說)。還請注意我修復了您在那裏濫用非英語變量的情況。 – nonchip