“拖动”移动 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用触摸移动事件来移动视图。 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.