UIScrollView做图片缩放
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. UIScrollView * scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame]; //第一步设置代理 scrollView.delegate = self; [self.view addSubview:scrollView]; //第二步设置缩放倍数 scrollView.minimumZoomScale = 1.0; scrollView.maximumZoomScale = 3.0; //图片 UIImageView * imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"详细信息"]]; [scrollView addSubview:imageView]; self.imageView = imageView; }
实现代理
//第三步,缩放的view -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ return self.imageView; }