本文主要是介绍计算Label的高度,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ios7:CGSize size2 = [lable1.text sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(168, 20000.0f)];
NSLog(@"label高度:%f",size2.height);
ios8:
NSDictionary *attributes =@{NSFontAttributeName:[UIFontsystemFontOfSize:17]};
CGSize textSize = [lable1.textboundingRectWithSize:CGSizeMake(168,2000) options:NSStringDrawingUsesLineFragmentOriginattributes:attributes context:nil].size;
NSLog( @"label高度:%f",textSize. height);这篇关于计算Label的高度的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!