我想为iOS制作一个fidget spinner模拟器。我有点像初学者,但我做了一些研究。但是,我仍然无法找到以下问题的答案:
如何找到用户滑动的速度和方向,并将图像旋转速度设置为滑动速度?
答案 0 :(得分:2)
您可以使用UIPanGestureRecognizer来获得滑动速度,但是对于方向,您应该比较滑动动作的起点和终点并找出方向。
- (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer
{
CGPoint velocity = [gestureRecognizer velocityInView:yourView];
}
答案 1 :(得分:0)
我使用下面的这些功能来创建根据手指位置移动的轮盘。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
查看这篇文章: https://blog.mellenthin.de/archives/2012/02/13/an-one-finger-rotation-gesture-recognizer/