NSString *htmlString = [NSString stringWithFormat:@"<font size='4'><div align='right'>共<font color='red'> %lu </font>件商品, 总计<font color='red'> %.2f </font></div></font>",(unsigned long)totalProduct,[self allMoneyTips]];
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
UILabel 加载html类文本
最新推荐文章于 2023-09-07 15:23:43 发布
本文介绍了一种使用Objective-C将带有格式的HTML字符串转换为NSAttributedString的方法,通过NSData和NSAttributedString的initWithData方法实现,适用于iOS应用中富文本的显示。
3306

被折叠的 条评论
为什么被折叠?



