在進行圖片處理的過程中,經常遇到類似於圖片縮放的需求,以前做個一個用pinch手勢對imageView進行縮放的例子,demo下載
下面就scrollView自帶的圖片縮放功能進行簡單的介紹: 首先實現UIScrollerViewDelegate協議,並設置其delegate 設置最大放大倍數:maximumZoomScale 為float類型 和 最小縮小倍數:minimumZoomScale 實現 - (UIView*)viewForZoomingInScrollerView:(UIScrollerVIew*)scroller{}方法即可 示例如下scrollerView=[[UIScrollView alloc]initWithFrame:self.view.bounds]; scrollerView.delegate=self; scrollerView.minimumZoomScale=0.5f; scrollerView.maximumZoomScale=2.0f; UIImageView *imageView=[[UIImageView alloc]initWithFrame:self.view.bounds]; [imageView setImage:[UIImage imageNamed:@"20091121014197_2.jpg"]]; [scrollerView addSubview:imageView]; [self.view addSubview:scrollerView]; - (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView { for (id view in [scrollerView subviews]) { if ([view isKindOfClass:[UIImageView class]]) { return view; } } return nil; }