'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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)