UIImageView and UIScrollView zooming

后端 未结 6 1648
抹茶落季
抹茶落季 2020-12-04 19:45

Do I actually need a UIPinchGestureRecognizer inside a UIScrollView to have the pinch working? If yes how do I do it? I am trying to implement what flipboard has, where it b

6条回答
  •  借酒劲吻你
    2020-12-04 20:16

    All you need to do is add your UIImageView (or any view you want to zoom) inside your UIScrollView.

    Set your maximumZoomScale on your UIScrollView to any value higher than 1.0f.

    Set yourself as the delegate of your UIScrollView and return the UIImageView in the viewForZooming delegate method.

    That's it. No pinch gesture needed, no nothing. UIScrollView handles pinch zooming for you.

提交回复
热议问题