计算文字宽高

计算宽高

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

你可能感兴趣的:(计算文字宽高)