Possible Duplicate:
UITextView formatting with fontname and bold
I am trying to Bold selected text of UITextView
.I don't want to use UIWebView
in my application.
How can I do that programmatically in UITextView
????
Possible Duplicate:
UITextView formatting with fontname and bold
I am trying to Bold selected text of UITextView
.I don't want to use UIWebView
in my application.
How can I do that programmatically in UITextView
????
Try -
textViewInstance.font = [UIFont boldSystemFontOfSize:14];
Edit 1: I didn't notice your statement of selected text
. This just bolds the entire text. Sorry ;)
I was facing a similar issue. According to the documentation and the lack of answers from google, I doubt there's a solution as UITextView has only one format setting for all its text. It's all or nothing for UILabels and UITextView. The only way I see it, is to use UIWebView which gives you more freedom of styling individual words and text in the view. Good luck. :)
In UITextView i dont have any idea but i am done this in UILabel.
First set text in UILabel and setFrame of that label according to the text Height. After that use the regular Expression for the get frame for text which you want to make bold and add new label on that frame with bold font and text.
If you want to demo for above explanation then see the below link. It's have nice implementation.
Edit: Now you can make selected text bold using "NSMutableAttributedString". See below peace of code.
NSString * string = @"<Your Full String>";
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc]initWithString:string];
[attStr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} range:NSMakeRange(0, string.length)];
NSString * subString = @"<String that you want to make bold>";
[attStr addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13], NSForegroundColorAttributeName:[UIColor redColor]} range:[string rangeOfString:subString]];
[<Your UILabel Object> setAttributedTitle:attStr forState:UIControlStateNormal];
Thanks, MinuMaster