问题描述
在UITextView中是否可以设置字体名称,然后将其设置为粗体?
In a UITextView is it possible to set the fontname and then set it to bold?
我知道可以使用fontWithName:(NSString *)fontName大小:(CGFloat)fontSize
I know that font name and size can be set usingfontWithName:(NSString *)fontName size:(CGFloat)fontSize
但是一旦完成,我该如何使其变粗呢?
But once this is done how can i make it bold?
推荐答案
iPhone上的系统字体出于许多目的是不错的选择.您可以使用内置字体类方法轻松地以常规,粗体或斜体样式选择它.例如
The system font on the iPhone is a good choice for many purposes. You can easily select it in a regular, bold or italic style using built-in font class methods. For example
UIFont *mainTitleFont = [UIFont boldSystemFontOfSize:14.0];
UIFont *subTitleFont = [UIFont SystemFontOfSize:14.0];
UIFont *textFont = [UIFont italicSystemFontOfSize:12.0];
但是,如果您想同时使用粗体和斜体或者完全使用另一种字体,该怎么办?在这种情况下,您可以按如下方式使用"fontWithName"方法.
But what if you want a font using both bold and italic at the same time, or a different typeface altogether? In that case, you can use the "fontWithName" method as follows.
UIFont *altFont = [UIFont fontWithName:@"Courier-Bold" size:14.0];
这篇关于字体名称和粗体的UITextView格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!