I am developing in IOS , I use the following code to set a background to the navigationBar
.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bar-back"] forBarMetrics:UIBarMetricsDefault];
And I want to add a image on navigationBar
and center of navigationBar
like the following picture.
How to add a image at the center of navigationBar in Objective-C ?
Thanks in advance.
Set navigation title view like below
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.png"]];
UIImage *img = [UIImage imageNamed:@"1.png"];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[imgView setImage:img];
// setContent mode aspect fit
[imgView setContentMode:UIViewContentModeScaleAspectFit];
self.navigationItem.titleView = imgView;