Search code examples
iosuiscrollviewzooming

Zoom two UIScrollViews synchronously.


I have two UIScrollViews. Both the scroll views contain an image. Now, I want to zoom second scroll view programmatically if I zoom in the first scroll view manually. I am using -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView method to manually zoom the first scroll view. The second scroll view should be zoomed to the same point and scale. How can I achieve this?


Solution

  • Try something like this in the UIScrollViewDelegate method:

    override func scrollViewDidScroll(scrollView: UIScrollView){
        otherScrollView.contentOffset = scrollView.contentOffset
        otherScrollView.zoomScale = scrollView.zoomScale
    }