ios7 UILabel sizeWithFont方法的最新写法 ios7之后 摒弃了 sizeWithFont方法,那么该怎么改写呢 不换行 CGSize fontSize = [string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15}]; 换行的话,首先要设置 UILabel 的 numberOfLines属性等于0,而后再计算Size NSAttributedString *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;