Created
August 24, 2011 15:03
-
-
Save mrjjwright/1168260 to your computer and use it in GitHub Desktop.
TUIAttributedString as hyperlink
This file contains 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
+(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