我做了一個應用程序,它設置了睡眠定時器的時鐘。基本上它是單手時鐘,用戶可以移動以設置他的睡眠時間。我試圖旋轉圖像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