Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoiphonedev/a69f5db06bfed25db47679005bafa2d4 to your computer and use it in GitHub Desktop.
Save leoiphonedev/a69f5db06bfed25db47679005bafa2d4 to your computer and use it in GitHub Desktop.
Selector for UITapGestre added to UILable and telling us wether user tap on desired text or not
//MARK:- tappedOnLabel
@objc func tappedOnLabel(_ gesture: UITapGestureRecognizer) {
guard let text = self.lblTermsAndConditions.text else { return }
let privacyPolicyRange = (text as NSString).range(of: "privacy policy")
let termsAndConditionRange = (text as NSString).range(of: "terms and condition")
if gesture.didTapAttributedTextInLabel(label: self.lblTermsAndConditions, inRange: privacyPolicyRange) {
print("user tapped on privacy policy text")
} else if gesture.didTapAttributedTextInLabel(label: self.lblTermsAndConditions, inRange: termsAndConditionRange){
print("user tapped on terms and conditions text")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment