我想在文本的一部分上加“粗体”,但我做不到。
我正在使用这个:
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"this is a part of the text"];
NSRange selectedRange = NSMakeRange(5, 10);
[string beginEditing];
[string addAttribute:NSFontAttributeName
value:[NSFont fontWithName:@"Helvetica-Bold" size:12.0]
range:selectedRange];
[string endEditing];
我收到错误“使用未声明的标识符 NSFontAttributeName”;
我该怎么做?
最佳答案
从 iOS 6.0 开始,NSFontAttributeName
应该可以正常工作。对于文档,请检查 NSAttributedString UIKit Additions。 https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSAttributedString_UIKit_Additions/
关于iphone - 输入粗体文本时出错 - Objective-C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9190771/