optonaut / ActiveLabel.swift

UILabel drop-in replacement supporting Hashtags (#), Mentions (@) and URLs (http://) written in Swift
MIT License
4.47k stars 686 forks source link

Handle tap if not on ActiveElement #93

Closed johnstonmatt closed 7 years ago

johnstonmatt commented 8 years ago

Is there a way to handle all other taps on the label that don't match a specific active element, without breaking the active element detection?

johnstonmatt commented 8 years ago

I tried putting a UITapGestureRecognizer on the label but that breaks detection of taps on active elements.

mortyccp commented 8 years ago

My suggestion would be use UITapGestureRecogniser to replace the ActiveLabel onTouch and exposing the recogniser. So you can use the UIGestureRecogniserDelegate to handle this.

Another way should be simply add private var tapHandler: (() -> ())? and change the OnTouch function .Ended switch case to call tapHandler on .None.

polqf commented 8 years ago

There is a work going on where you can provide a custom handler for an Element, so when it is done, you can create it, and give it the same text as the color, and you're going to have it.

But as I said, is a going on work ATM

alkincakiralar1996 commented 6 years ago

i cant do it please help me i've been trying a lot of hours please