1
votes

I know there is many topics for this subject but I didn't found a good solution for my problem. I have a UIScrollView with an image and other components added as subviews. I just want to know the good way to resize the components into in real time when I zoom.

- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
    // Resizing image and other components
}

EDIT : I would like the impression that the components inside the scroll view keep the same size when I zoom. I don't want to they become bigger or smaller during zooming.

EDIT : Here is the hierarchy of my UIViewController

  • View
    • ScrollView
      • Main view
        • Image view
        • Drawing view (UIView with components like UILabel, other UIViews, etc...)

Thanks a lot !

1

1 Answers

1
votes

I would leave the scale of UIScrollView as it is and reach the goal with the help of subview (adjusting its size, not scrollView's), where I would place all the subviews and the images you work with. So it would be something like:

yourView.transform = CATransform3DMakeScale(newScale, newScale, 1.0);

where yourView is the main (only) subview of scrollView. Then I would recalculate the size of the yourView with new scale and set it to scrollView's contentSize parameter so that you could actually scroll the enlarged content, not only see it truncated.

The only thing is that in this case you should use the callback other than scrollViewDidZoom: I guess.

P.S. Changing UIView's transform parameter you don't need to bother about subviews' scale: CoreAnimation does everything for you.