/*
options:NSStringDrawingUsesFontLeading 计算宽度
NSStringDrawingUsesLineFragmentOrigin 计算高度
*/
//计算宽度时,size高度为实际高度,高度为最大宽度
//计算高度时,size宽度为实际宽度,高度为最大高度
//1 已遗弃
CGSize size = [_text sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:CGSizeMake(300,5000)];
//2
CGRect rect = [_text boundingRectWithSize:size options:NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName : _locationTitle.font} context:nil];
//3
CGSize size = [_text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]}];
单元格文本自适应
最新推荐文章于 2023-05-10 15:26:49 发布