Reputation: 1312
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
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
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:
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
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