我怎样才能走动,滑开与触摸和挥笔一个UIView? [英] How can I move around and slide away a UIView with touches and swipes?

查看:124
本文介绍了我怎样才能走动,滑开与触摸和挥笔一个UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试动画一种可拖动的UIView的地方行为应该是这样的:

I´m trying to animate a sort of draggable UIView where the behaviour should be something like this:


  • 沿以下用户的触摸屏幕上拖动。

  • 检测轻扫触控和初始速度和负加速度,使得一段时间后,自动停止拖动。

喜欢的东西周围相片移动,然后通过它向屏幕的一侧。

Something like moving around a photo and then through it to one side of the screen.

在这个任何提示?

推荐答案

一个类似的问题约3个星期前被要求(由我)。虽然一些我收到的答案是有点没谱,最好的建议是:1 - 学习苹果的的 MoveMe的例子如何触摸对象和周围拖动。 到 [触摸previousLocationInView:self.view]:和2-您可以通过比较基本在 [self.view触摸locationInView]扔的对象在 < STRONG> touchesEnded (也可以存储在第一触摸参考的的touchesBegan 的,但我发现,当用户可以暂停不太有用)使用每个时间戳可以判断刷卡的方向(甩尾)和速度的速度,并利用它们来发送你的小UIView的飞来飞去。显然,要应用力(摩擦)或任何要慢下来,因此它不会飞屏幕右侧...

A similar question was asked (by me) about 3 weeks ago. Though some of the answers I received were a little off the mark the best advice was: 1- study Apple's MoveMe example for how to touch an object and drag it around. And 2- you "throw" the object by basically comparing the [touch locationInView:self.view] to the [touch previousLocationInView:self.view] in touchesEnded (could also store a reference to first touch in touchesBegan but I find that less helpful as user may pause) using the time stamp of each you can determine the direction of swipe (flick) and rate of speed and use them to send your little UIView flying around. Obviously you want to apply forces ("friction") or whatever to slow it down so it doesn't fly right of your screen...

这篇关于我怎样才能走动,滑开与触摸和挥笔一个UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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