i need to find heigh开发者_如何转开发t for a label with certain text based on its font and length. It requires to be generic to hold font as well as a parameter.
To get the height of a NSString object using sizeWithFont: method.
NSString *theText = myLabel.text;
CGFloat width = myLabel.frame.size.width ;
CGSize theSize = [theText sizeWithFont:myLabel.font constrainedToSize:CGSize(width,MAXFLOAT) lineBreakMode:UILineBreakModeWordWrap];
Here is the height of your UILabel .
CGFloat myLabelHeight = theSize.height;
加载中,请稍侯......
精彩评论