4

I'm loading a font and setting it on a label like this

UIFont *font = [UIFont fontWithName:@"MyMonoFont" size:150.0];
label.font = font;
label.text = "TOBY"

However, it seems to clip or hide the bottom part of the text (as shown below). It works fine with another font I tried. Both fonts are TTF and are "valid" according to the "validate" action in Mac's Font Book app.

enter image description here

There are some constraints (it's auto layout) but as I say, anther font seems to cope ok.

Thanks for any hints.

EDIT: Bit of an update; updating the label frame size doesn't make a difference (if I have auto layout on). I'd like to keep auto layout on but suspect its clashing / resizing the frames. I wonder if theres a way for them to play nicely.

Arun_
  • 1,806
  • 2
  • 20
  • 40
Toby
  • 9,523
  • 8
  • 36
  • 59
  • 1
    Increase the height of the label. That font looks like it's significantly taller than most. – Mick MacCallum Nov 02 '12 at 13:27
  • In interface builder do you mean? I tried in code with label.frame = CGRectMake(x, y, width, height); but it didn't affect anything... – Toby Nov 02 '12 at 13:37

2 Answers2

6

Increase the height of frame of label according to font size of your label .

label.frame = your frame.
abhishekkharwar
  • 3,529
  • 2
  • 18
  • 31
  • Updating with something like label.frame = CGRectMake(time.frame.origin.x, time.frame.origin.y, time.frame.size.width, 250); seems to set the height (checked with NSLog(@"Height %f", time.frame.size.height); but it doesn't repaint. Would I need to force some kind of refresh after? – Toby Nov 02 '12 at 20:48
4

Use the sizeToFit method of UILabel to achieve this.

[label sizeToFit];

or manually compute the label's size and set the label's frame Dynamically changing font size of UILabel

Community
  • 1
  • 1
sunkehappy
  • 8,970
  • 5
  • 44
  • 65
  • I tried the sizeToFit with no luck, I'll try your other suggestion next – Toby Nov 02 '12 at 13:49
  • Sure, I've tried changing the height but the autoresize squashes things again (if I switch this off, the height works and the font will display fully, but I havn't figured out how to arrange things without autolayout). The sizeToFit seems to make no difference. – Toby Nov 06 '12 at 18:12