我遇到了一个小问题。
我需要使用一个句子,前两个单词为粗体,后两个单词为斜体。
就像我正在使用一个 Objective C 开发人员。
如何做到这一点。这在 Objective C 中可能吗?
问候,
最佳答案
对于 iOS7,你可以使用这个:
NSString * htmlString = @"<html><body> Some html string </body></html>";
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
UILabel * myLabel = [UILabel alloc] init];
myLabel.attributedText = attrStr;
关于objective-c - UILabel 文本为 html 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5743844/