Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
TUIAttributedString as hyperlink
+(id)hyperlinkFromString:(NSString*)inString withURL:(NSURL*)aURL
TUIAttributedString* attrString = [TUIAttributedString stringWithString:inString];
NSRange range = NSMakeRange(0, [attrString length]);
[attrString beginEditing];
[attrString addAttribute:NSLinkAttributeName value:[aURL absoluteString] range:range];
// make the text appear in blue
NSColor *blueColor = [TUIColor colorWithHexString:@"#3B5998"].nsColor;
[attrString addAttribute:NSForegroundColorAttributeName value:blueColor range:range];
[attrString endEditing];
return attrString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment