如何通过触摸该图像旋转箭头图像? [英] How can i rotate an arrow image by touch on that image?

查看:183
本文介绍了如何通过触摸该图像旋转箭头图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,我需要通过触摸它来旋转图像。

I am working on a project where i need to rotate an image by touching it.

它可以根据用户的触摸方式更快或更慢。

It can be rotate faster or slower depending on how the user touches it.

您能告诉我一些教程或如何做到这一点吗?

Can you show me some tutorials or how this can be done?

推荐答案

将图像放在UIImageView中,然后将该视图子类化,并替换touchesBegan:withEvent:或为其设置一个委托,并实现与委托方法相同的方法。这将使您能够响应触摸事件(触摸的开始,在这种情况下,虽然您可以做同样的结束触摸或移动手指)。

Place your image within a UIImageView, then either subclass that view and replace touchesBegan:withEvent: or set a delegate for it and implement the same method as a delegate method. This will give you the ability to respond to touch events (the beginning of a touch, in this case, although you can do the same for ending a touch or moving of the finger).

在这种触摸处理方法中,您可以实现类似于我描述的内容此处,以便以给定速度执行启用Core-Animation的旋转UIImageView。要改变速度,请更改我提供的动画的duration属性。正如我在那里建议,你可能想研究一个CAKeyframeAnimation做一个更流畅的动画加速和减速在开始和结束。

Within this touch handling method, you can implement something similar to what I describe here in order to perform a Core-Animation-enabled rotation of your UIImageView at a given speed. To alter the speed, change the duration property on the animation I provide. As I suggest there, you may want to look into a CAKeyframeAnimation to do a smoother animation with acceleration and deceleration at the beginning and end.

这篇关于如何通过触摸该图像旋转箭头图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆