>当用户点击按钮时
>当用户按下按钮并将他/她的手指拖出按钮区域时
>当用户将他/她的手指从按钮区域外拖到按钮区域内
基本上,任何时候触摸按钮的任何部分,无论触摸的来源,我想要触发方法,但希望通过 *** 作UIbutton属性来完成此 *** 作,如touchUpInsIDe等.
谢谢你的建议!
解决方法 关于:When the user presses the button and drags his/her finger out of the button’s area
我最近做了类似的事情.这是我在Swift中的代码.
(在此示例中,您将UIbutton子类化,如:class Fadingbutton:UIbutton)
...// The user tapped the button and then moved the finger around.overrIDe func touchesMoved(_ touches: Set<UItouch>,with event: UIEvent?) { super.touchesMoved(touches,with: event) // Get the point to which the finger moved if let point: CGPoint = touches.first?.location(in: self) { // If the finger was dragged outsIDe of the button... if ((point.x < 0 || point.x > bounds.wIDth) || (point.y < 0 || point.y > bounds.height)) { // Do whatever you need here } }}...
我希望它对某人有帮助.
总结以上是内存溢出为你收集整理的ios – 当用户将手指拖入按钮区域时触发UIButton的方法?全部内容,希望文章能够帮你解决ios – 当用户将手指拖入按钮区域时触发UIButton的方法?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)