You should give UIColor to Color;
Stepper(value: $age, in: 1...60)
{
Text("(String(format: "%.0f",44.456)) Mins")
.font(.body)
.foregroundColor(Color("font"))
}
.background(Color(UIColor(named: "Color1")!))
You need to unwrap UIColor(named: "Color1")
as it is an optional value. You can do it in different ways according to what you need. One solution might be like;
let color1: UIColor = UIColor(named: "Color1") ?? .white
var body: some View {
HStack{
Text("Count : ")
.font(.body)
.foregroundColor(Color(.blue))
Spacer()
Stepper(value: $age, in: 1...60)
{
Text("(String(format: "%.0f",44.456)) Mins")
.font(.body)
.foregroundColor(Color("font"))
}
.background(Color(color1))
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…