我想像愤怒的小鸟一样在触摸时滚动单个图像。我可以使用任何手势来滚动单个图像吗?并且不使用手势如何滚动图像?请帮我。谢谢你。
问问题
128 次
1 回答
0
您可以使用 pinchgesturesrecognizer 滚动图像。这是代码。
UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]
initWithTarget:self action:@selector(scaleImage:)];
[self.view addGestureRecognizer:pinchGesture];
- (void)scaleImage:(UIPinchGestureRecognizer *)recognizer
{
if([recognizer state] == UIGestureRecognizerStateEnded) {
previousScale = 1.0;
return;
}
CGFloat newScale = 1.0 - (previousScale - [recognizer scale]);
CGAffineTransform currentTransformation = yourimage.transform;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransformation, newScale, newScale);
yourimage.transform = newTransform;
previousScale = [recognizer scale];
}
于 2012-05-26T08:45:01.887 回答