0
NSString *str = @"We’ll notify you before we make changes to these 
terms and give you the opportunity to review and comment on the revised 
terms before continuing to use. If you have any question just email 
me.";
NSMutableAttributedString *aStr = [[NSMutableAttributedString 
alloc]initWithString:str attributes:nil];
[str rangeOfString:@"email"]];
[self.textView setAttributedText:aStr];

this is my text i want create link on email.

Inder_iOS
  • 1,636
  • 1
  • 12
  • 20
  • You should try this: http://stackoverflow.com/questions/26962530/hyperlinks-in-a-uitextview – nynohu May 11 '17 at 06:03

2 Answers2

2

you can do something like,

NSString *str = @"We’ll notify you before we make changes to these terms and give you the opportunity to review and comment on the revised terms before continuing to use. If you have any question just email me.";
NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc]initWithString:str attributes:nil];
[aStr addAttribute:NSLinkAttributeName value:@"Your Link here" range:[str rangeOfString:@"email"]];
[self.textView setAttributedText:aStr];

Update

You can add font attribute to make it bold. For example if you want to make We’ll notify bold then

  [aStr addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14.0] range:[str rangeOfString:@"We’ll notify"]];

add this line before you set attributed text to your textView !

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
0

Add this property to your textview

textview.dataDetectorTypes = UIDataDetectorTypeLink;
Nupur Sharma
  • 1,106
  • 13
  • 15