名为StepProgressView的时间线库没有委托或数据源。所以我不能用我的键在迭代中改变文本颜色。
link
我有我的项目标题和字幕阵列。当我在数组中添加标题时,它会给我带数组项的时间线。
这是我打印时的字典输出。
[17: "17 Kind of long rambling explanation that no one reads in reality",
14: "14 Kind of long rambling explanation that no one reads in reality",
20: "20 Kind of long rambling explanation that no one reads in reality"
但当我迭代时,它会填充键值的最后一种颜色。这是我的问题。我希望它是清楚的。
for (key, _) in self.stepDetails {
progressView.pastTextColor = getColor(key: key)
}
func getColor(key: Int) -> UIColor {
switch key {
case 0...key:
return .red
case key ... key + 10:
return .blue
default:
return .gray
}
}
它总是给出最后一种颜色,因为它在迭代中,所以
在这种情况下,最好的方法是什么?