I have the following code which calculate the height of my label depends on the text I set the label to. But what I find out is it is always 40 pixels more than it should (I trial and error to find that value 40). Does anyone have the same problem? If yes, what is the possible solution?
NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:myLabel.font forKey:NSFontAttributeName]; // width is the width of the label CGSize size = CGSizeMake(width, NSUIntegerMax); CGSize expectedLabelSize = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:stringAttributes context:nil].size; // expectedLabelSize.height is 40 pixel than it should. // If I manually - 40 from the value expected