是否可以实现UILabel的touchdown?
最佳答案
UILabel
是 UIView
的子类,而 UIView 本身又是 UIResponder
的子类;因此,制作一个响应触摸的标签绝对是可能的。只需创建一个新的 UILabel
子类并实现以下方法:
– touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
因此,如果您希望在触摸开始时发生某些事情,可以在 -touchesBegan:withEvent:
中执行。
如果创建一个新的子类对您来说太繁重,那么我建议按照 @JustSid 的建议进行操作,并使用 UIButton
来完成该任务。
关于iphone - UILabel + touchDown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4158099/