Tap gesture implementation for label rxswift

Problem: 

I want to implement the tap gesture to the label using rxswift. How to implement?


Solution:

Code:

        let tapGesture = UITapGestureRecognizer()

        lbl.addGestureRecognizer(tapGesture)

        lbl.isUserInteractionEnabled = true


        tapGesture.rx.event

            .subscribe(onNext: { [weak self] _ in

                self?.myfunc()

            })

            .disposed(bydisposeBag)


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift