UITextField使文本粗体? [英] UITextField make text bold?

查看:91
本文介绍了UITextField使文本粗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题,是否有人知道如何以文字方式将文字以粗体斜体进行编程?

Quick question, does anyone know how to programatically make the text in the textField bold or italic?

   @property(nonatomic, retain) IBOutlet UITextField *textField_TOP_01;

   [textField_TOP_01 setTextColor:[UIColor redColor]];
   [textField_TOP_01 setText:@"This text is bold"];

非常感谢。

Gary

推荐答案

您可以使用以下方法获取粗体或斜体系统字体;

You can use the following methods to get a bold or italic system font;

UIFont* boldFont = [UIFont boldSystemFontOfSize:[UIFont systemFontSize]];
UIFont* italicFont = [UIFont italicSystemFontOfSize:[UIFont systemFontSize]];

然后只需设置文本字段使用的字体;

Then simply set the font that the text field uses;

[textField_TOP_01 setFont:boldFont];

如果你想更多地了解iPhone的字体,你可以看到一个漂亮的屏幕截图的可用字体: http://www.drobnik.com/touch/2010/02/understanding -uifont / 或者你可以阅读关于类,它显示你如何也可以拉出'buttonFontSize'和'labelFontSize'等在这里; http://developer.apple.com/library/ios/# documentation / uikit / reference / UIFont_Class / Reference / Reference.html

If you want to see more about fonts with the iPhone, you can see a nice screen shot of all of the available fonts here: http://www.drobnik.com/touch/2010/02/understanding-uifont/ or you can read about the class which shows you how you can also pull out the 'buttonFontSize' and 'labelFontSize' etc here; http://developer.apple.com/library/ios/#documentation/uikit/reference/UIFont_Class/Reference/Reference.html

这篇关于UITextField使文本粗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆