Created
July 29, 2015 14:38
-
-
Save smmcdonald/02134334edf6d3921ea1 to your computer and use it in GitHub Desktop.
Web links in UITextViews
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
| NSMutableAttributedString *yourText = [[NSMutableAttributedString alloc] initWithString:@"Your block of text goes here."]; | |
| // Value:urlLink, Key:blueText | |
| NSDictionary *links = [[NSDictionary alloc] initWithObjectsAndKeys:@"http://www.google.com", @"here", nil]; | |
| // Search and replace key words in the text with actual links | |
| for (NSString *link in [links allKeys]) { | |
| NSRange range = [consentCopy.string rangeOfString:link]; | |
| [consentCopy addAttribute:NSLinkAttributeName value:[links valueForKey:link] range:range]; | |
| } | |
| [yourTextView setAttributedText:yourText]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment