Last Updated: September 29, 2021
·
18.41K
· _jeffreyjackson

Custom Title in Navigation Bar

You can replace the titleView of the navigationItem. Here is a simple example using a UILabel.

- (void)viewDidLoad
{
    [super viewDidLoad];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont fontWithName:@"GoodMobiPro-CondBold" size:24];
    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
    label.textAlignment = UITextAlignmentCenter;
    label.textColor = [UIColor whiteColor]; 
    self.navigationItem.titleView = label;
    label.text = @"My Custom Title";
    [label sizeToFit];
}