ios5.0 introduced a bunch of features to customize the look of standard elements. If you do not want to use ImageView for the title, an alternative would be to customize the appearance of all UINavbars using a background image and a custom font / color.
- (void) customiseMyNav { // Create resizable images UIImage *portraitImage = [[UIImage imageNamed:@"nav_bar_bg_portrait"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; UIImage *landscapeImage = [[UIImage imageNamed:@"nav_bar_bg_landscape"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; // Set the background image [[UINavigationBar appearance] setBackgroundImage:portraitImage forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundImage:landscapeImage forBarMetrics:UIBarMetricsLandscapePhone]; // set the title appearance [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [UIColor colorWithRed:50.0/255.0 green:150.0/255.0 blue:100/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.6], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset, [UIFont fontWithName:@"Arial-Bold" size:0.0], UITextAttributeFont, nil]]; }
joneswah Aug 22 2018-12-12T00: 00Z
source share