我有一个图像视图
我可以使用以下代码用两根手指放大和缩小图像
{
[super viewDidload]
imageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320 ,420)];
[imageScrollView addSubview:imgView];
// imageScrollView.minimumZoomScale=0.75;
imageScrollView.maximumZoomScale=6.0;
imageScrollView.zoomScale = 0.29;
imageScrollView.delegate=self;
[self.view addSubview:imageScrollView];
}
//UIScrollViewDelegate methods for Zoom
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imgView;
}
- (CGRect)zoomRectForScrollView:(UIScrollView *)ImgscrollView withScale:(float)scale withCenter:(CGPoint)center
{
CGRect zoomRect;
zoomRect.size.height = ImgscrollView.frame.size.height / scale;
zoomRect.size.width = ImgscrollView.frame.size.width / scale;
// choose an origin so as to get the right center.
zoomRect.origin.x = center.x - (zoomRect.size.width / 2.0);
zoomRect.origin.y = center.y - (zoomRect.size.height / 2.0);
return zoomRect;
}
但我的要求是使用滑动值而不是两指缩放来增加或减少缩放级别。
- (IBAction) sliderValueChange:(UISlider *)sender
{
//--- ???????
}
通过更改滑块值来增加图像增加的缩放级别,并通过减小滑块值来降低缩放级别