我正在使用 LazyVGrid 显示日历月,并希望 Sat 和 Sun 列具有不同的背景颜色。
LazyVGrid(columns: columns, spacing: 34) {
ForEach(daysForMonthView, id: \.self) { day in
Text(dayFormatter.string(from: day.start))
.fontWeight(.semibold)
.foregroundColor(
currentDisplayMonth.contains(day) ? .primary : .secondary
)
.background (
ZStack {
if let selectedDay = selectedDay, selectedDay == day {
RoundedRectangle(cornerRadius: 4)
.fill(Color(white: 0.3))
.frame(width: 30, height: 30)
}
if day.contains(Date()) {
RoundedRectangle(cornerRadius: 4)
.stroke(Color.secondary, lineWidth: 1)
.frame(width: 30, height: 30)
}
practiceSymbolRow(forDay: day)
.offset(y: 20)
}
)
.onTapGesture {
selectedDay = day
}
}
}