I am putting a UILabel in a custom UIImageView and the text is being cut off:

Code:
//self.frame.size.width and height are the same value, self is a square
self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (self.frame.size.width - 12), (self.frame.size.height - 12))];
self.displayNameLabel.center = CGPointMake((self.frame.size.width / 2), (self.frame.size.height / 2));
self.displayNameLabel.backgroundColor = [UIColor whiteColor];
self.displayNameLabel.textAlignment = UITextAlignmentCenter;
self.displayNameLabel.font = [UIFont fontWithName:labelFont size:40];
self.displayNameLabel.adjustsFontSizeToFitWidth = YES;
I set the font size large and then use adjustsFontSizeToFitWidth to make sure it’s as large as it can be. It states:
If this property is set to YES, however, and the text in the text property exceeds the label’s bounding rectangle, the receiver starts reducing the font size until the string fits
If I set the label.frame to:
self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (self.frame.size.width - 0), (self.frame.size.height - 0))];
Then it works as intended.
How does setting the frame to:
self.frame.size.width
self.frame.size.height
instead of:
self.frame.size.width - 14
self.frame.size.height - 14
work?
Why is it getting clipped on the top?
The property
adjustsFontSizeToFitWidthwill only cause the label to adjust the font size until the width of the string fits within the frame. If the label is not tall enough to accommodate the final font size it will be clipped.