1. 程式人生 > >UILabel 載入html類文字

UILabel 載入html類文字

    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];