I wanted to make a Gauge View to display the angle Moved below is the image
and the needle give the angle according to the input is given ,but I need to change the direction of the needle with some animation as of now its just moving like a glitch
below is my code
import SwiftUI
struct RudderView: View {
@State var ArrowValue: CGFloat = -100
let AngleTimer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect()
var body: some View {
NavigationView {
ZStack{
Circle()
.stroke(.gray.opacity(0.1),lineWidth: 25)
Circle()
.trim(from: 0,to: 0.75)
.stroke(Gradient(colors: [.red,.white,.green]), style: StrokeStyle(lineWidth: 25,lineCap: .round,lineJoin: .round))
.rotationEffect(Angle(degrees: -225))
ZStack {
RoundedRectangle(cornerRadius: 20)
.foregroundColor(.white)
.frame(width: 25, height: 150)
}
.offset(x:0, y: -50)
.rotationEffect(Angle(degrees: ArrowValue))
.onReceive(AngleTimer) { _ in
withAnimation {
}
}
}
Text("40")
.font(.largeTitle)
.fontWeight(.thin)
.foregroundColor(.white)
.offset(x:100, y:170)
Text("-40")
.font(.largeTitle)
.fontWeight(.thin)
.foregroundColor(.white)
.offset(x:-100, y:170)
}
.padding()
}
}
}
struct RudderView_Previews: PreviewProvider {
static var previews: some View {
RudderView()
.preferredColorScheme(.dark)
}]w
}
can anyone say what to type in the animation bracket to move my needle smoothly according to the changes of input for arrow