UITextView formatting with fontname and bold
In a UITextView is it possible to set the fontname and then set it to bold?
I know that font name and size can be set using fontWithName:(NSString *)fontName size:(CGFloat)fontSize
But on开发者_运维百科ce this is done how can i make it bold?
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];
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];
Reference
Use the Bold variant of the font, e.g. @"Helvetica-Bold"
as the fontName
. If using the default system font is ok for you, you can also use boldSystemFontOfSize:
method instead.
UIFont *f = [UIFont fontWithName:@"Verdana-Bold" size:12];
yourTextView.font = f;
If you want to give font with name then you can refer below link. It have all font which are provided by iOS with their font names.
iOS Fonts
Thanks.
精彩评论