I'm developing an app which uses a custom font but I'm experiencing some unusual clipping. I think the problem is with the font itself, but I've no way to fix that, so i need to come up with a solution to work around it within the app.
I'm using the font for the navigationBar title, here's what's happening:
You can see that font is sitting too high from the baseline which is why the clipping is occurring.
I've managed to find an almost-suitable solution replacing the standard navigationBar title with a UILabel, inserting it in to the navigationBar's titleView
.
UILabel *navTitle = [[UILabel alloc] init];
navTitle.frame = CGRectMake(0,0,190,40);
navTitle.text = @"My Title Text";
navTitle.font = [UIFont fontWithName:AGENDA_TYPE_FONT size:17];
navTitle.backgroundColor = [UIColor clearColor];
navTitle.textColor = [UIColor colorWithHue:0.356 saturation:0.457 brightness:0.288 alpha:1.00];
navTitle.shadowColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.50];
navTitle.shadowOffset = CGSizeMake(0, 1);
navTitle.textAlignment = UITextAlignmentCenter;
// Set label as titleView
self.navigationItem.titleView = navTitle;
// Shift the title down a bit...
[self.navigationController.navigationBar setTitleVerticalPositionAdjustment:9 forBarMetrics:UIBarMetricsDefault];
This works because I've made the label twice the height it should be, which brings the text fully into view.
The problem with this though is that it now sits far too low (outside of the navigationBar. As below...
I can't think of a way to fix this, or even another way around this. I've tried overriding the frame origin height, but this does nothing.
Can anyone offer any help on this?