计算文字宽度和高度
2016-09-01 本文已影响352人
LGirl
计算文字宽度
NSString *content = @"欢迎来到北京";
CGSize size =[content sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
计算文字高度
NSString *str = @"我爱北京天安门";
CGRect textRect = [str boundingRectWithSize:CGSizeMake(200, 2000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil];