0

I want to add an image in my navigation bar. To do this, i wrote that :

        self.navigationItem.titleView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"logo.png"]];

It's running, but the only problem is the image seems to be blurred. When i look it on photoshop or other software, the image is perfect.

The size of this image is : 120 x 30px.

Someone to help me ? Thx

deveLost
  • 1,151
  • 2
  • 20
  • 47

2 Answers2

1

First of all, please, print self.navigationItem.titleView.frame after your viewDidAppear.

Seems to be, that in some case your titleView is placed with half-pixeled origin.x, or origin.y.

Try to play with:

[self.navigationController.navigationBar setTitleVerticalPositionAdjustment:<#(CGFloat)#> forBarMetrics:<#(UIBarMetrics)#>]

Try to set different values to the first param and observe the result.

Krivoblotsky
  • 1,492
  • 11
  • 17
  • Sorry, i solved the problem, i needed to add an other image with "@2x" for the retina screen. Thx for your help. – deveLost Mar 11 '14 at 09:57
0

You can change the navigation and status bar background only in iOS7. For this, you can use

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"yourImage.png"] forBarMetrics:UIBarMetricsDefault];

The size should be 320*64 px

and to change the Navigation Bar title

self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.png"]];
Himanshu Joshi
  • 3,391
  • 1
  • 19
  • 32
  • Sorry, i solved the problem, i needed to add an other image with "@2x" for the retina screen. Thx for your help. – deveLost Mar 11 '14 at 09:56