计算宽高
CGSize size = [@"hello" sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12]}];
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@""];
NSRange range = [[attString string] rangeOfString:name];
[attString addAttribute:NSForegroundColorAttributeName value:color range:range];
[attString addAttribute:NSFontAttributeName value:font range:range];
[lLabel setAttributedText:attString];
网友评论