我制作了一个应用程序,它用时钟设置睡眠定时器。基本上它是一个时钟,它有一只手,用户可以移动它来设置他的睡眠时间。我试图用uitouch旋转图像,但它从中间旋转,但我想要它从尖端旋转。其次,我希望图像仅在用户触摸图像的尖端时旋转,但在我的项目中,当使用触摸屏幕的任何部分时,图像也会旋转。我也想在两个方向上旋转图像但在我的项目中,由于这种方法,它只能顺时针移动
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");
}