A UIScrollView subclass that resizes itself to fit around its content.
In your Podfile, add this line:
Add a scrollview:
Assign it the class of
Set up your min and max zoom and such:
Set your content insets to something reasonable (so your content isn't right up against the scrolling edges)
Add some content to your fitted scrollview:
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)]; v.backgroundColor = [UIColor redColor]; [_fittedScrollView addZoomableSubview:v];
Add some more content, but at an offset of 1000 (so its way outside the current scrollable area):
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(x + 1000, y + 1000, w, h)]; v.backgroundColor = [UIColor redColor]; [_fittedScrollView addZoomableSubview:v];
fit on the scrollview:
And magically, the scrollview fits around it's content so you an scroll and zoom all of it.
Make sure you clone this repo and try out the demo app so you can see how it works.
Autolayout has some pretty nasty bugs with scrollviews. If you're trying to do fancy stuff with scrollviews & auto layout, have fun. ...Then file a bug with Apple.