'drag' 移动一个 uibutton,使它像 uiScrollView

#39;drag#39; move a uibutton so it acts like uiScrollView(drag 移动一个 uibutton,使它像 uiScrollView)

本文介绍了'drag' 移动一个 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!

推荐答案

您可以使用 touch 移动事件来移动视图.Apple 提供了一个示例教程 MoveMe视图并在释放触摸后为视图设置动画.特别检查 MoveMeView.m 了解他们如何移动 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.

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

本文标题为:'drag' 移动一个 uibutton,使它像 uiScrollView

基础教程推荐