Xcode creates interactive text

I am trying to create an object that can contain text with text in it.

For example: I have the text displayed to the user: "Please check the terms and conditions before registering."

I want to make only the text of the "terms and conditions" as a link. The text will be highlighted in blue.

When the user clicks on the text, I want them to be moved to my terms and conditions page. Thus, the link is internal to the application, and not an external web page.

Questions

  • How to display text only by binding specific text?
  • How do I go to a ViewController page with a user click on related text?
+4
source share
1 answer

You can do this with TTTAttributedLabel . From the readme file:

Besides supporting rich text, TTTAttributedLabel allows you to automatically identify links to URLs, addresses, phone numbers and dates, or let you insert your own.

label.dataDetectorTypes = UIDataDetectorTypeAll; // Automatically detect links when the label text is subsequently changed label.delegate = self; // Delegate methods are called when the user taps on a link (see `TTTAttributedLabelDelegate` protocol) label.text = @"Fork me on GitHub! (http://github.com/mattt/TTTAttributedLabel/)"; // Repository URL will be automatically detected and linked NSRange range = [label.text rangeOfString:@"me"]; [label addLinkToURL:[NSURL URLWithString:@"http://github.com/mattt/"] withRange:range]; // Embedding a custom link in a substring 
+4
source

Source: https://habr.com/ru/post/1440061/


All Articles