本文介绍了'拖'移动一个uibutton,使其像uiScrollView一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在屏幕上上下滑动一个uibutton(仅限Y)。它需要局限于一个区域。我希望能够点击它并拖动轻弹它,就像uiScrollView一样。与uiScrollView不同的原因是你必须从按钮开始,而不是uiScrollView内的任何地方!

I need to slide a uibutton up and down the screen (Y only). It needs to be confined to an area. I want to be able to click on it and drag or flick it, just like a uiScrollView. The reason it is different to a uiScrollView is that you have to start on the button, as opposed to anywhere inside a uiScrollView!

推荐答案

您可以使用触摸移动事件移动视图。有一个示例教程由Apple推出视图和释放触摸后为视图设置动画。在以了解他们如何移动placardView。您可以像placardView一样移动按钮。

You can move a view by using touch moved event. There is a sample tutorial MoveMe by Apple which drags a view and after releasing the touch animate the view. Check specially the touch events (touchesBegan, touchesMoved, touchesEnded) in MoveMeView.m to get the idea how they have moved placardView. You can move your button just like the placardView.

这篇关于'拖'移动一个uibutton,使其像uiScrollView一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 03:06