简体   繁体   中英

UITextView Bold Font iphone sdk

我试图加粗/斜体文本,但我使用此代码加粗我的字体,但当我整个按下粗体按钮时,UITExtView将变为粗体,但我想选择一些文本和粗体/斜体或更改它们的颜色..

textPad.font = [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:

  1. Place your textView at the desired location
  2. Select the textView and open up the Attributes tab under the Utilities panel
  3. Change the textView text to "attributed"
  4. Enter your desired text
  5. Now, highlight whatever text you want bolded, underlined, etc.
  6. Click on the "T" button next to the fontName
  7. In the popup, select your desired typeface (ex: Bold)
  8. You should see the desired typeface displayed in the Utilities panel

Enjoy!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM