ios 获取字符串所需要占用的label的高度

//    设置字体大小

UIFont *fnt=[UIFont systemFontOfSize:16];

NSDictionary *attribute = @{NSFontAttributeName: fnt};

//     CGSize retSize; 全局变量

retSize = [Remark[0] boundingRectWithSize:CGSizeMake(SCREEN_WIDTH, 0)

options:\

NSStringDrawingTruncatesLastVisibleLine |

NSStringDrawingUsesLineFragmentOrigin |

NSStringDrawingUsesFontLeading

attributes:attribute

context:nil].size;

labels1 = [[UILabel alloc]initWithFrame:CGRectMake(10, Lastview.frame.size.height/2+SCREEN_WIDTH/10, SCREEN_WIDTH-20, retSize.height)];

labels1.numberOfLines = 0;

labels1.font =fnt;

labels1.textColor =[UIColor colorWithWhite:0.663 alpha:1.000];

labels1.text = Remark[0];

[Lastview addSubview:labels1];

上一篇:PAT L2-023 图着色问题


下一篇:Android屏幕适配框架-(今日头条终极适配方案)