我以前处理过这样的事情。所以,这会对你有所帮助。我也为你测试过它并且工作正常:)
NSString *string = @"A |picture| is worth *1000* words.";
// Create an NSMutableAttributedString in order to be able to use the NSAttributedString+Attributes.h category
NSMutableAttributedString *attributedString = [NSMutableAttributedString attributedStringWithString:string];
// If using custom fonts, import all styles in the app and update the plist file
[attributedString setFont:[UIFont fontWithName:@"Helvetica" size:20.0]];
// Parse the markup and set the attributedText of the UILabel instance (no need to use the OHAttributedLabel subclass)
attributedString = [OHASBasicMarkupParser attributedStringByProcessingMarkupInAttributedString:attributedString];
label.attributedText = attributedString;
编辑:-setFont:
在调用之后使用时会出现问题-attributedStringByProcessingMarkupInAttributedString
,因为这会重置解析期间完成的所有工作。