Shefali Soni
Shefali Soni

Reputation: 1312

Using custom fonts : digital-7 fonts for Label

Did anybody used digital-7 fonts in UILabel, i found text to align in bottom(aligns too low on the Y axis instead of being in the vertical center of the label). do anybody has solution to show them center aligned?

Upvotes: 0

Views: 372

Answers (3)

Hiren
Hiren

Reputation: 12780

I had used custom fonts in my project earlier. Just you have to add the font.tff file in your project and set your font with setFont method

Upvotes: 0

Dan Rosenstark
Dan Rosenstark

Reputation: 69777

What you're asking about, with that particular font, is that it aligns too low on the Y axis instead of being in the vertical center of the label. Some solutions:

  1. get a font manager and fix the font by hand
  2. adjust the UILabel instances or a UILabel subclass to push it up higher than it is. You could do this by intercepting a setFrame call, for instance.

As far as I can see, UIFont does not carry that information with it at all. It might, though: you can check some of the read-only properties of the font.

With that said, however, you still can't set properties on a font, so you cannot adjust it in this way.

Upvotes: 1

Mudit Bajpai
Mudit Bajpai

Reputation: 3020

try this..

UILabel *testLabel    = [[UILabel alloc] initWithFrame:CGRectMake(148, 142, 130, 25)];
[testLabel setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:20]];
[testLabel setText:@"MY Text"];
[testLabel setTextColor:[UIColor darkGrayColor]];
[testLabel setBackgroundColor:[UIColor clearColor]];
[testLabel setTextAlignment:UITextAlignmentCenter];

Upvotes: 0

Related Questions