IOS 7 Study

Problem
You want to display an image instead of text as the title of the current view controller
on the navigation controller


Solution
Use the titleView property of the view controller’s navigation item

- (void)viewDidLoad {
    [super viewDidLoad];

    /* Create an Image View to replace the Title View */
    UIImageView *imageView =
        [[UIImageView alloc]
        initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 40.0f)];
    imageView.contentMode = UIViewContentModeScaleAspectFit;

    /* Load an image. Be careful, this image will be cached */
    UIImage *image = [UIImage imageNamed:@"Logo"];

    /* Set the image of the Image View */
    [imageView setImage:image];
    
    /* Set the Title View */
    self.navigationItem.titleView = imageView;
}
原文地址:https://www.cnblogs.com/davidgu/p/3557340.html