如何使粗体字体NSString值? [英] how to make bold font NSString value?
问题描述
像这样
架构i386的未定义符号:
_kCIAttributeName,
NSString * boldFontName = [[UIFont boldSystemFontOfSize:12] fontName];
NSString * yourString = [NSString stringWithFormat:@%@%@%@,key,@:,@];
NSRange boldedRange = NSMakeRange(22,4);
NSMutableAttributedString * attrString = [[NSMutableAttributedString alloc] initWithString:yourString];
[attrString beginEditing];
[attrString addAttribute:kCIAttributeName
value:boldFontName
range:bolddedRange];
[attrString endEditing];
NSString * string = [NSString stringWithFormat:@%@%@,attrString,[dic objectForKey:key]];
可以帮助我如何在字符串中加粗字体。
谢谢
NSString
用于存储没有任何字体格式的简单文本。
$ b
UILabel
有一个 font
属性,你可以使用它在 UI
上设置可见文本的字体,但是 UILabel
可以只使用一种格式,整个文本将获得相同的字体和样式。
if你真的想使用一种丰富的文本文档,你应该创建一个 I am new in iPhone application development. i am developing now iPhone application. In this application i want make bold font in NSString value. How can i achieve this. I am used below code for making bold font text in NSString value. But showing error like this
Undefined symbols for architecture i386:
"_kCIAttributeName", can you help me how to make bold font in string. Thanks the the if you really want to use a kind of rich text document, you should create a the 这篇关于如何使粗体字体NSString值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! UIWebView
类,你可以用标准 HTML显示任何文档
$ b 更新
UILabel
可以存储归因字符串,即使使用各种字体或大小等等,也可以在单个 UILabel
实例中显示丰富格式的文本。 ... NSString *boldFontName = [[UIFont boldSystemFontOfSize:12] fontName];
NSString *yourString = [NSString stringWithFormat:@"%@%@%@",key,@":",@" "];
NSRange boldedRange = NSMakeRange(22, 4);
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:yourString];
[attrString beginEditing];
[attrString addAttribute:kCIAttributeName
value:boldFontName
range:boldedRange];
[attrString endEditing];
NSString *string = [NSString stringWithFormat:@"%@%@",attrString,[dic objectForKey:key]];
NSString
is for store a simple texts without any font formatting.UILabel
has a font
property, you can use it to set the visible text's font on the UI
, but the UILabel
can work with one format only and the whole text gets the same font and style.
UIWebView
class and you can show any document inside with the standard HTML
tags.
UPDATE
UILabel
can store attributed string since iOS6, which gives you a chance to show rich-formatted text in one single UILabel
instance, even using various fonts or sizes, etc...