Instead of using UITapGestureRecognizer
you can use UILongPressGestureRecognizer
to get the different state.
Like this:
let tapgr = UILongPressGestureRecognizer(target: self, action: #selector(tapTrigger(recongizer:)))
tapgr.minimumPressDuration = 0
bottomBar.addGestureRecognizer(tapgr)
@objc func tapTrigger(recongizer: UITapGestureRecognizer){
if recongizer.state == .began{
print("recognised")
} else if recongizer.state == .ended{
print("ended") //prints
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…