【发布时间】:2012-10-30 12:19:02
【问题描述】:
我正在尝试为UIImageView 实现UIRotationGestureRecognizer。
UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[self.view addGestureRecognizer:rotateGesture];
在选择器方法中,我没有这个
-(void)rotate:(UIRotationGestureRecognizer *)gesture
{
if ([gesture state] == UIGestureRecognizerStateBegan || [gesture state] == UIGestureRecognizerStateChanged) {
selectedImage.transform=CGAffineTransformRotate(selectedImage.transform, gesture.rotation);
[gesture setRotation:0];
}
}
使用上面的代码,图像正在旋转。但是,问题是,图像中心正在改变。这样,图像旋转看起来有点尴尬。
图片的初始中心是(277,653)
旋转时,价值会增加直到(365,659),然后又回到(277,653)。
可能是什么原因?怎么解决中心问题?如何使用UIRotationGestureRecognizer 使我的图像在UIImageView 的中心旋转?
【问题讨论】:
标签: iphone ios5 uigesturerecognizer cgaffinetransform image-rotation