简体   繁体   中英

Add Hyperlink to Storyboard using Swift

I would like to add a link to my main story board but can't seem to find a way to do it. I've seen a post detailing how to do here it but it seems the Behavior options are different and there aren't any Detection options. Any help would be appreciated.

As per the suggestions adding a tap gesture to a Label implements a simple hyperlink. Here's the code I used in the ViewController:

@IBOutlet weak var contactUrl:  UIView!

var webView = WebViewClient()


@objc func contactUrlTapped(_ sender: UITapGestureRecognizer)
{
    let myURL = URL(string: "https://google.com")

    let myRequest = URLRequest(url: myURL)

    webView.load(myRequest)
}

override func viewDidLoad()
{
    super.viewDidLoad()

    let contactUrlAction = UITapGestureRecognizer(target: self, action: #selector(self.contactUrlTapped(_:)))
    contactUrl.isUserInteractionEnabled = true
    contactUrl.addGestureRecognizer(contactUrlAction)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM