Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created August 24, 2011 15:03
Show Gist options
  • Save mrjjwright/1168260 to your computer and use it in GitHub Desktop.
Save mrjjwright/1168260 to your computer and use it in GitHub Desktop.
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