Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created December 17, 2020 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/73cf387992a2c696564ddb526031d3df to your computer and use it in GitHub Desktop.
Save laevandus/73cf387992a2c696564ddb526031d3df to your computer and use it in GitHub Desktop.
var didTapOnURL: (URL) -> Void = { url in
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: { success in
if success {
print("Opened URL \(url) successfully")
}
else {
print("Failed to open URL \(url)")
}
})
}
else {
print("Can't open the URL: \(url)")
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if let url = self.url(at: touches) {
didTapOnURL(url)
}
else {
super.touchesEnded(touches, with: event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment