Reputation: 15245
I have UIScrollview
with a couple of UIViews
init.
If I scale it doesn't really scale my scrollview
but it scales the content in my scrollview
in a very weird way,
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 60.0f, self.bounds.size.width, self.bounds.size.height-60.0f)];
[self addSubview:_scrollView];
[_scrollView.layer setAffineTransform:CGAffineTransformScale(_scrollView.layer.affineTransform, .5, .5)];
Is it possibly to scale the scrollview
in its whole and not only the content.
I want to zoom it like my UIScrollView
as an image and not a control.
Upvotes: 0
Views: 111
Reputation: 612
you can do it if you add a UIScrollView inside UIScrollView and use the delegate method:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return innerScroll;
}
and only connect the mainScroll to the delegate then add your subviews inside the innerScroll
Upvotes: 0
Reputation: 604
You can try this:
- (CGRect)zoomRectForScale:(float)scale withScrollView:(UIScrollView *)yourScrollView {
CGRect zoomRect;
zoomRect.size.height = [yourScrollView frame].size.height / scale;
zoomRect.size.width = [yourScrollView frame].size.width / scale;
zoomRect.origin.x = (yourScrollView.theScrollView.x - zoomRect.size.width / 2.0);
zoomRect.origin.y = (yourScrollView.center.y - zoomRect.size.height / 2.0);
return zoomRect;
}
...
[yourScrollView setFrame:[self zoomRectForScale:5 withScrollView:yourScrollView]];
Upvotes: 1