SimultaneousGesture in Swiftui rotate and scale don't work if only one is triggered

Viewed 149

A simple example from RayWenderlich, but it's not working, if only one gesture is triggered. Example: If you scale and rotate is working. If you scale only not working after that, you are not able to do any gestures, same case if you rotate only. Maybe is BUG in SwiftUI?

var body: some View {
        let magnify = MagnificationGesture()
          .updating($gestureScale) { value, state, _ in
            state = (value - 1)
            print("magni")
          }
        
        let rotate = RotationGesture()
          .updating($gestureRotation) { value, state, _ in
            state = value
            print("rotate")
          }
        
        let magnifyRotate = SimultaneousGesture(magnify, rotate)
          .onEnded { value in
            self.scale += (value.first ?? 0) - 1
            self.rotation += value.second ?? Angle(degrees: 0)
            print("end")
          }
        
        return VStack(spacing: 50.0) {
          Text(animalName)
            .font(.largeTitle)
          
          Image(systemName: "note")
            .resizable()
            .scaledToFit()
            .frame(width: 300, height: 300)
            .scaleEffect(scale + gestureScale)
            .rotationEffect(rotation + gestureRotation)
            .gesture(magnifyRotate)
        }
      }
    }
0 Answers
Related