-
(float)
heightForString: (NSString *)str
fontSize: (float)fontSize andWidth:
(float)width{
CGSize sizeToFit =
[str sizeWithFont:
[UIFontsystemFontOfSize: fontSize]
constrainedToSize: CGSizeMake(width,CGFLOAT_MAX)
lineBreakMode:NSLineBreakByWordWrapping]; // 可根据具体需求设置lineBreakMode
return sizeToFit.height;
}