我在scrollView
中有很多imageViews
。问题是我不希望其中一个的图像被放大。我不能将imageView
移动到scrollView
之外,因为它必须根据scrollView
中的缩放和平移手势来改变位置(帧)。有没有机会不放大这个imageView
的图像?
由于imageViews的大小与容纳它们的滚动视图的大小不同,您可以通过以下实现这一点
-
从UIScrollView派生一个类,并在其中添加UIImageView。如下所示:
@interface MyScrollView : UIScrollView <UIScrollViewDelegate> @property(nonatomic,retain)UIImageView *imageView; @end @implementation -(id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; { self.delegate = self; self.minimumZoomScale = 1.0f; self.maximumZoomScale = 3.0f; self.bounces= NO; self.imageView = [[UIImageView alloc] initWithFrame:self.bounds]; [self addSubview:self.imageView]; } return self; } -(UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView { return self.imageView; } @end
-
现在,您可以将上述MyScrollView的实例添加到实际的scrollView中。这将类似于scrollView中的scrollViews。
-
使按住滚动条View不可缩放。
-
在每个滚动视图中添加您的图像,方法如下:
[myScrollViewInstance.imageView集图像:myImage];
这样,在执行捏手势时,只有捏下面的imageView才会放大或缩小。