大佬教程收集整理的这篇文章主要介绍了ios – 当用户将手指拖入按钮区域时触发UIButton的方法?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>当用户点击按钮时@H_301_10@>当用户按下按钮并将他/她的手指拖出按钮区域时@H_301_10@>当用户将他/她的手指从按钮区域外拖到按钮区域内
基本上,任何时候触摸按钮的任何部分,无论触摸的来源,我想要触发方法,但希望通过操作UIButton属性来完成此操作,如touchUpInside等.
谢谢你的建议!
(在此示例中,您将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的方法?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。