skip to Main Content

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

2

Answers


  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.

    Login or Signup to reply.
  2. 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"]];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search