问题描述
为了控制我的应用程序中的所有颜色,我创建了一个包含静态颜色变量的枚举。
enum Color {
static var mainColor = UIColor(named: "mainColor")
static let red = UIColor(named: "red")
static let blue = UIColor(named: "blue")
static let green = UIColor(named: "green")
static let magenta = UIColor(named: "magenta")
static let indigo = UIColor(named: "indigo")
static let orange = UIColor(named: "orange")
static let pink = UIColor(named: "pink")
static let purple = UIColor(named: "purple")
static let yellow = UIColor(named: "yellow")
static let white = UIColor(named: "white")
}
我在我的应用中到处都使用 mainColor 作为背景。但是在我的 SettingsView 中,有这些颜色的集合,当您点击其中一个时,我想将 mainColor 更改为它。
func collectionView(_ collectionView: UICollectionView,didSelectItemAt indexPath: IndexPath) {
if collectionView == settingsView.primary.collection{
let color = collectionView.cellForItem(at: indexPath)?.backgroundColor
Color.mainColor = color
}
}
我该怎么做?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)