Can I set image as a title to UINavigationBar?
You can use an UIImageView
for the UINavigationItem.titleView
property, something like:
self.navigationItem.titleView = myImageView;
I find that a transparent .png at about 35px in height has worked well.
- (void)awakeFromNib {
//put logo image in the navigationBar
UIImageView* img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]];
self.navigationItem.titleView = img;
[img release];
}
You can do it right from storyboard (as of Xcode 7):
- Create a view outside main view of view controller. It can be a nested view or just an image
- Add navigation item to your view controller
- Ctrl+ drag from navigation item and drop on outside view
4.select title view