#import "QYViewController.h"
@interface QYViewController ()<UIScrollViewDelegate>
{
UIImageView *_imageView;
}
@end
@implementation QYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//1.加入UIScrollerView
UIScrollView *scrollView = [[UIScrollView alloc]init];
scrollView.frame = self.view.bounds;
//把scrollView加入到视图
[self.view addSubview:scrollView];
//2.加入图片
UIImage *image = [UIImage imageNamed:@"4"];
_imageView = [[UIImageView alloc]initWithImage:image];
//设置代理
scrollView.delegate = self;
//设置最小伸缩比例
scrollView.minimumZoomScale = 0.2;
//设置最大伸缩比例
scrollView.maximumZoomScale = 2.0;
//3.设置内容范围
scrollView.contentSize = image.size;
//将_imageView加入到scrollView视图
[scrollView addSubview:_imageView];
}
#pragma mark - 这种方法返回的控件就能进行捏合手势缩放操作
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return _imageView;
}