
-(void)setContent:(NSString*)content {
_content=content;
_attributedTitle = [self createAttributedWithString:content font:LYFont(Scale(Font16)) color:@"#303133"];
}
- (NSMutableAttributedString *)createAttributedWithString:(NSString *)str font:(UIFont*)strFont color:(NSString *)color{
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@""];
if(str && strFont){
str = [selfcompareWithHtlmColor:strcolor:color];
attrString = [[NSMutableAttributedString alloc] initWithData:[str dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
style.lineBreakMode = NSLineBreakByTruncatingTail;
[attrStringaddAttribute:NSFontAttributeName value:strFont range:NSMakeRange(0, attrString.length)];
[attrStringaddAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, attrString.length)];
}
returnattrString;
}
- (NSString*)compareWithHtlmColor:(NSString*)strcolor:(NSString*)color{
return [NSString stringWithFormat:@"
%@",color,str];}
网友评论