Hello World !
I need your help to perform a button rotation on my "VStack" view My "Foreach" loop defines a multitude of buttons for me. I would like it to rotate when I press a button. When I put a common variable, the code does not give me an error but all the buttons rotate. So I used a dictionary to make the buttons standalone but the code gave me an error.
How can I make my buttons autonomous in the rotation while keeping my "foreach" loop?
Thank you !
//Variable
@State private var TableauRotationEffect:[String:Double] = ["":0.0]
//Main Code in my view
ForEach(1..<Int(nombreSerie)!+1, id: \.self) { numSerie in
HStack(spacing: 20) {
Text ("\(numSerie) // \(nombreSerie):").frame(width:200).font(.system(size: 13, weight: .regular)).foregroundColor(.gray).offset(x: 60, y: 0)
Button {
TableauRotationEffect["Ser:\(numSerie)"] = 90
print("Bouton anime 1 \(DateDebutSeance) // \(numeroExercice) // \(numeroSerie)")
} label: {
Label("Graph", systemImage: "chevron.right.circle")
.labelStyle(.iconOnly)
.imageScale(.large)
.rotationEffect(.degrees(TableauRotationEffect["Ser:\(numSerie)"]))
.padding()
.animation(.easeInOut, value: showDetail)
.frame(height:10)
}.onAppear() {
TableauRotationEffect["Ser:\(numSerie)"] = 0
}
}
}