2013-08-23 82 views
-3

我有一個項目,在屏幕上圍繞UIImageView來完成不同的功能,但是視圖中的實際圖像是靜態的,我實際上希望它旋轉到你拖動,所以如果你拖動UIImage離開,我希望圖像旋轉到左邊並留在那裏,如果你然後拖動圖像旋轉到上位置等等。當你在屏幕上拖動圖像時旋轉UIImageView

+0

這聽起來像一個有趣的項目。祝你好運! – chrylis

回答

0

你可以應用旋轉的視圖變換:

view.transform = CGAffineTransformMakeRotation(angleInRadians); 

您可以隨時移除變換過:

view.transform = CGAffineTransformIdentity; 
+0

嗨,感謝您的帖子,我有以下代碼,我只想「船」面對同樣的方式作爲拖動,如果這是有道理的,不知道在哪裏把代碼: –

+0

- (void)touchesBegan: (NSSet *)觸及事件:(UIEvent *)事件UITouch * touch = [[event allTouches] anyObject]; \t CGPoint位置= [touch locationInView:touch.view]; \t ship.center = location; (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { } - (void touchesBegan:touches withEvent:event]; [self ifCollided]; } –