Create Mutable Attributed string, do following steps
NSMutableAttributedString * attrString = [[NSMutableAttributedString alloc] initWithString:yourTextView.text];
1) Found Hello!
range and set font with size
NSRange foundRange = [attrString rangeOfString:@"Hello!"];
if (foundRange.location != NSNotFound)
{
[attrString beginEditing];
[attrString addAttribute: NSFontAttributeName
value:[[UIFont boldSystemFontOfSize:17] fontName]
range:boldedRange];
[attrString endEditing];
}
2) Search range for only 30 seconds
and set underline style
foundRange = [attrString rangeOfString:@"only 30 seconds"];
if (foundRange.location != NSNotFound)
{
[attrString beginEditing];
[attrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:1] range:foundRange];
[attrString endEditing];
}
3) Search range for once!
and set stroke color.
foundRange = [attrString rangeOfString:@"once!"];
if (foundRange.location != NSNotFound)
{
[attrString beginEditing];
[attrString addAttribute:NSStrokeColorAttributeName value:[UIColor redColor] range:foundRange];
[attrString endEditing];
}
Finally set attributed string to your textview as
yourTextView.attributedText = attrString;
Note: The above only work with ios6+.
.