Note that there are some explanatory texts on larger screens.

plurals
  1. POFont cut-off in navigationBar title
    text
    copied!<p>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.</p> <p>I'm using the font for the navigationBar title, here's what's happening:</p> <p><img src="https://i.stack.imgur.com/jBhIh.png" alt="NavBar Broken"></p> <p>You can see that font is sitting too high from the baseline which is why the clipping is occurring.</p> <p>I've managed to find an almost-suitable solution replacing the standard navigationBar title with a UILabel, inserting it in to the navigationBar's <code>titleView</code>.</p> <pre><code> 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]; </code></pre> <p>This works because I've made the label twice the height it should be, which brings the text fully into view.</p> <p><img src="https://i.stack.imgur.com/bs6NA.png" alt="Partial Solution"></p> <p>The problem with this though is that it now sits far too low (outside of the navigationBar. As below...</p> <p><img src="https://i.stack.imgur.com/gic53.png" alt="Out of bounds"></p> <p>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.</p> <p>Can anyone offer any help on this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload