UITextView Bold Font iphone sdk
iam trying to bold / italic text but i use this code to bold my font but when i press bold button whole the UITExtView going to bold but i want select some text and bold / italic or change the color of them ..
textPad.font开发者_StackOverflow中文版 = [UIFont boldSystemFontOfSize:12];
You can't. UITextView
is all one font. Simplest way to get proper text styling is to use a UIWebView
instead.
I know this is an old thread, but this is something I just discovered myself. At least in Xcode version 4.6.3 this is possible by using an attributed textView. What's even better is that it's possible to all be done in Interface Builder!
Here are the steps:
- Place your textView at the desired location
- Select the textView and open up the Attributes tab under the Utilities panel
- Change the textView text to "attributed"
- Enter your desired text
- Now, highlight whatever text you want bolded, underlined, etc.
- Click on the "T" button next to the fontName
- In the popup, select your desired typeface (ex: Bold)
- You should see the desired typeface displayed in the Utilities panel
Enjoy!
精彩评论