像旋转瓶子一样旋转UIImage

时间:2009-08-12 15:37:07

标签: iphone

我不知道你们中是否有人知道iPhone的Spin the Bottle应用程序。我想制作一个简单的应用程序,为用户提供带瓶子的简单图像。用户应该能够通过手指手势旋转瓶子。他/她应该能够用手指旋转它并且在释放之后(触摸结束),瓶子应该进一步旋转并减速直到它停在基于速度的位置。

解决方案的任何线索或提示?

2 个答案:

答案 0 :(得分:2)

如果您自己了解所有内容会更好,但如果您想要一个更具体的示例,则代码here可以正常工作
Narut的帖子就像第5个回复一样,有很好的清洁代码,可以满足您的需求。

答案 1 :(得分:1)

为了响应自定义多点触摸手势(例如旋转),您需要子类化图像视图或包含它的视图,并构建以下方法的自定义实现:

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

基本上,将iPhone屏幕视为图形,将手指视为点。您可以在视图中使用上述方法来确定手指在图表上的方式/位置。

良好的起点:

http://developer.apple.com/IPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html

https://stackoverflow.com/questions/tagged/multi-touch+iphone