注意:这是我将此手势添加到我的imageview
的方式UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
pinchGesture.delegate=self;
[self.editPictureImageView addGestureRecognizer:pinchGesture];
注意:这是我处理夹点转换的方法 mcurrentscale和mlastscale属于浮点型
-(void)handlePinch:(UIPinchGestureRecognizer*)sender {
mCurrentScale += [sender scale] - mLastScale;
mLastScale = [sender scale];
if (sender.state == UIGestureRecognizerStateEnded)
{
mLastScale = 1.0;
}
if (mCurrentScale < 1)
{
mCurrentScale = 1.0;
}
CGAffineTransform currentTransform = CGAffineTransformIdentity;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, mCurrentScale, mCurrentScale);
self.editPictureImageView.transform = newTransform;
}
plzz帮助
答案 0 :(得分:0)
这可能是一种更尴尬的方式。
我会重新考虑你的方法:
将UIImageView
添加到UIScrollView
。 imageView的框架应该是scrollView的边界,我的意思是在它的默认位置,imageView应该像在坐在普通视图中一样坐在scrollView中。
设置UIScrollView(IB或代码):
self.scrollView.delegate = self;
// example values
self.scrollView.minimumZoomScale = 0.4f;
self.scrolLView.maximumZoomScale = 3.0f;
采用这种方法:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
// allow zooming of our image view
return self.imageView;
}