Вам не нужен подкласс для создания массива:
let listColors = [
UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1),
UIColor(displayP3Red: 2, green: 2, blue: 2, alpha: 1),
UIColor(displayP3Red: 3, green: 3, blue: 3, alpha: 1)
]
access
listColors[index]
или
class Colors {
static let color1 = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1)
static let color2 = UIColor(displayP3Red: 2, green: 2, blue: 2, alpha: 1)
static let color3 = UIColor(displayP3Red: 3, green: 3, blue: 3, alpha: 1)
}
доступ
Colors.color1
или как глобальный
let color1 = UIColor(displayP3Red: 1, green: 1, blue: 1, alpha: 1)
let color2 = UIColor(displayP3Red: 2, green: 2, blue: 2, alpha: 1)
let color3 = UIColor(displayP3Red: 3, green: 3, blue: 3, alpha: 1)
доступ
color1
При создании цвета разделите на 255
UIColor(displayP3Red: 2/255.0, green: 2/255.0, blue: 2/255.0, alpha: 1)