Last active
December 28, 2019 16:07
-
-
Save ycui1/776a361d3494813ccab17b353e109324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc func didTapLabel(sender: UITapGestureRecognizer) { | |
var tappedImage = false | |
if let index = label.characterIndexTapped(tap: sender), let _ = label.attributedText?.attribute(NSAttributedString.Key.attachment, at: index, effectiveRange: nil) as? NSTextAttachment { | |
tappedImage = true | |
} | |
let alertTitle = tappedImage ? "Tapped Image":"Random Taps" | |
let alertMessage = tappedImage ? "You just tapped the image.":"You just tapped outside the image." | |
let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .actionSheet) | |
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil)) | |
present(alertController, animated: true, completion: nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment