ios7 UILabel sizeWithFont方法的最新写法ios7以后 摒弃了 sizeWithFont方法,那么该怎么改写呢不换行CGSize fontSize = [string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15}];换行的话,首先要设置 UILabel 的 numberOfLines属性等于0,然后再计算SizeNSAttributedString *name = [[NSAttributedString alloc]initWithString:string attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}]; CGRect nameRect = [name boundingRectWithSize:CGSizeMake("你想要的宽度", CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil]; CGSize nameSize = nameRect .size;