在这里,我试图在这两个元素中应用相同的旋转。但是这些对象或元素正在做不想要的行为,它们的旋转与其他元素不同。所以我想把它们都旋转成相同的,这样蓝卡就不会出现在图像后面。我的意思是我希望他们都在同一个轮换中。
这是我的代码 -
var body: some View {
VStack(spacing : 10){
ZStack {
ZStack (alignment : .bottom){
ZStack(alignment : .bottom){
Image("cat")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: length, height: length)
Text("<>")
.frame(width: 20, height: 20)
.padding()
.background(Color.orange)
.cornerRadius(15)
}
.frame(width: length, height: length)
.background(.blue)
.rotationEffect(Angle(degrees: Double(-totalRotation.width)))
Text("<>")
.frame(width: 20, height: 20)
.padding()
.background(Color.orange)
.cornerRadius(15)
.gesture(
DragGesture()
.onChanged { value in
totalRotation.width = value.translation.width + currentRotation.width
}
.onEnded { value in
currentRotation = totalRotation
mainAngle = totalRotation
}
)
Text("\(mainAngle.width) --- \(totalRotation.width)")
.foregroundColor(.white)
}
.frame(width: length, height: length)
.background(.blue)
.rotationEffect(Angle(degrees: Double(-mainAngle.width)))
}
.frame(width: length, height: length)
.rotationEffect(Angle(degrees: Double(-mainAngle.width)))
}
.frame(width: length, height: length)
Text("\(angle)")
}
}[![Here the image to get much information][1]][1]