class ViewController: UIViewController {
NSMutableAttributedString * stringForLabel = [[NSMutableAttributedString alloc] initWithString: @"I accecpt the "];
NSMutableAttributedString * pPStr = [[NSMutableAttributedString alloc] initWithString: @"Privacy Policy"];
NSMutableAttributedString * and = [[NSMutableAttributedString alloc] initWithString: @" and "];
NSMutableAttributedString * tNCStr = [[NSMutableAttributedString alloc] initWithString: @"Terms and Conditions"];
[pPStr addAttribute: NSLinkAttributeName value: @"http://www.google.com" range: NSMakeRange(0, pPStr.length)];
[tNCStr addAttribute: NSLinkAttributeName value: @"http://www.yahoo.com" range: NSMakeRange(0, tNCStr.length)];
[stringForLabel appendAttributedString:pPStr];
[stringForLabel appendAttributedString:and];
[stringForLabel appendAttributedString:tNCStr];
[stringForLabel addAttributes: @{NSFontAttributeName : [UIFont fontWithName:@"Helvetica" size:16.0]} range: NSMakeRange(0, stringForLabel.length)];
self.myTextView.attributedText = stringForLabel;
self.myTextView.linkTextAttributes = @{NSForegroundColorAttributeName:[UIColor redColor]};
Like this:
Like Loading...
Related
Leave a Reply