我做了一个应用程序,它设置了睡眠定时器的时钟。基本上它是单手时钟,用户可以移动以设置他的睡眠时间。我试图旋转图像uitouch但它从中间旋转,但我希望它从tip.Secondly旋转。其次,我希望该图像只旋转时,用户正在触摸图像的提示,但在我的项目中,图像也旋转时使用触摸任何部分的screen.Also我想在两个方向上旋转图像,但在我的项目是由于这种方法旋转图像
image.transform = CGAffineTransformRotate(image.transform, degreesToRadians(1));
任何人都可以给我提示或解决方案,如何做到这一点?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//
touch = [[event allTouches] anyObject];
touchLocation = [touch locationInView:touch.view];
NSLog(@"began");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
// get touch event
[image.layer setAnchorPoint:CGPointMake(0.0,0.0)];
if ([touch view] == image) {
image.transform = CGAffineTransformRotate(image.transform, degreesToRadians(1));
//image.center = touchLocation;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"end");
}
你能解释一下这个过程吗?我从代码中不太明白它,你如何设置所有东西来旋转视图? – 8vius 2011-06-27 20:02:57