【发布时间】:2016-09-29 20:45:47
【问题描述】:
我有以下代码:
deleteAllButton.setTitle("Delete", forState: .Normal)
deleteAllButton.titleLabel?.numberOfLines = 2
deleteAllButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
deleteAllButton.titleLabel?.font = UIFont.systemFontOfSize(keyboardFontSize)
// deleteAllButton.addTarget(self, action: #selector(deletekeyPressed), forControlEvents: .TouchUpInside)
let deleteLPGR = UILongPressGestureRecognizer(target: self, action: #selector(deleteButtonLongPress))
deleteLPGR.minimumPressDuration = 0
deleteLPGR.delaysTouchesBegan = true
deleteAllButton.addGestureRecognizer(deleteLPGR)
通常当按下 UIButton 时,文本会自动更改颜色以指示它处于“按下”状态。但是,由于我添加了长按手势识别器,因此该按钮并不表示它处于“按下”状态。
我怎样才能让触摸事件通过按钮,让用户感觉按钮实际上被“按下”了?
【问题讨论】:
标签: ios swift uibutton long-press uilongpressgesturerecogni