#39;drag#39; move a uibutton so it acts like 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
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01