首页 > 其他 > 详细

IOS 7 Study - Displaying an Image on a Navigation Bar

时间:2014-02-20 22:22:17      阅读:421      评论:0      收藏:0      [点我收藏+]

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

 

bubuko.com,布布扣
- (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;
}
bubuko.com,布布扣

IOS 7 Study - Displaying an Image on a Navigation Bar

原文:http://www.cnblogs.com/davidgu/p/3557340.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!