Below is my screen design.
.
I want Zoom in/out in **mainView*
When you are zooming in the scroll view, the zoomView
(mainView
in your case) is not resized, just an affine transformation applied on it's layer (CALayer
). For example in case of 1.2 zoomScale it is :[1.2, 0, 0, 1.2, 0, 0]
.
So it's bounds is not changed - just all of it's content scaled up/down, it also affects it's frame
property - so nor the contained inner view, and label will be resized, just scaled up/down when rendering the mainView, this is why their frame is unaffected.
Just implement - (void)scrollViewDidZoom:(UIScrollView *)scrollView
in the delegate and print out the main view's frame, bounds, layer.affineTransform
to see what happens on zooming.
To make what you want you have to adjust the label according the zoomScale
:
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
float zoomScale = scrollView.zoomScale;
self.label.bounds = CGRectMake(0, 0, 100*zoomScale, 100*zoomScale); // supposing that label's original size is {100, 100}
self.label.layer.affineTransform = CGAffineTransformMakeScale(1.0/zoomScale, 1.0/zoomScale);
}