[objc][memo] UINavigationBar のタイトルに画像を表示する。

More than 1 year has passed since last update.

UINavigationBar のタイトルに画像を表示する。


UIImage *titleImage = [UIImage imageNamed:@"HeaderLogo.png"];
UIImageView *titleImageView = [[UIImageView alloc] initWithImage:titleImage];
titleImageView.frame = CGRectMake(0, 0, titleImage.size.width * 0.5, titleImage.size.height * 0.5);//適当にサイズ調整

UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(-titleImage.size.width*0.5, 0, titleImageView.frame.size.width , titleImageView.frame.size.height)];
[titleView addSubview:titleImageView];
self.navigationItem.titleView = titleView;

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.