Given a rectangular area, I want to render some text using a specific font and have the rendered text fill out the rectangle. As in the image below:
you can also try with the UILabel's @property(nonatomic) BOOL adjustsFontSizeToFitWidth
and @property minimumFontSize
Initially you can set the much higher value for font property and also initialize the minimumFontSize
with a minimum font value.
You can set the UILabel transform property and scale the width:
[myLabel sizeToFit];
myLabel.transform = CGAffineTransformMakeScale(0.5, 1.0);
You could try CoreText. Get a CTFramesetter
, calculate its rect, then calculate the affine transform necessary to compress that rect into the bounds you want and set that as the CTM. Then when you draw the text, it should stretch it appropriately at full quality.