0

I have a standart app with a view, which you can scale in/out by pinch gesture. It's work, but I have a little delay at first, it look like jumpy zoom. Does anybody know a solution to make it work smoother ? Example of code here:

VStack {
Image("image")
    .resizable()
    .scaledToFill()
    .frame(width: UIScreen.main.bounds.width, height: 200)
    .scaleEffect(scale)
    .gesture(MagnificationGesture()
        .updating($scale, body: { (value, scale, trans) in
            scale = value.magnitude
        })
)

}

1 Answers1

0

In order to solve the "jumpy zoom" you only need to add an animation.

Maybe something like this for example :

Image("image")
            .resizable()
            .scaledToFill()
            .frame(width: UIScreen.main.bounds.width, height: 200)
            .scaleEffect(scale)
            .gesture(MagnificationGesture()
                        .updating($scale, body: { (value, scale, trans) in
                    scale = value.magnitude
                })
            )
            .animation(Animation.easeInOut(duration: 2.0), value: scale)// Animation to solve the "jumpy zoom"

enter image description here

  • 1
    Due to peculiarities, working solution was to create UIKit gesture recogniser, but thanks for answer ! – DoNNy G Oct 29 '21 at 06:40