如何通过触摸该图像来旋转箭头图像?

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

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

问题描述

我正在做一个项目,我需要通过触摸来旋转图像.

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).

在这种触摸处理方法中,您可以实现类似于我描述的 这里以便以给定的速度对 UIImageView 执行启用 Core-Animation 的旋转.要更改速度,请更改我提供的动画的持续时间属性.正如我在那里建议的那样,您可能希望研究 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.

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

本文标题为:如何通过触摸该图像来旋转箭头图像?

基础教程推荐