I want to set a UIImageView with a UIImage
and put this imageview inside a UIScrollView
to obtain a zoom of this image;
and I want this UIImageView
and UIScrollView
to fit in the rect at the center of the view...is it possible?
<UIScrollViewDelegate>
UIScrollView
the size you want for the rectangle at the center of the view. Set the max zoom in the inspector to something bigger than 1. Like 4 or 10.UIImageView
in the UIScrollView
and set it up with whatever image you want. Make it the same size as the UIScrollView
.UIImageView
to the .h
of your View controller to create an IBOutlet
for the UIImageView
, call it something clever like imageView
.Add this code:
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; }
Run the app and pinch and pan til your heart's content.