deveLost
deveLost

Reputation: 1171

iOS Image in navigation Item titleview

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

Upvotes: 0

Views: 2225

Answers (2)

Himanshu Joshi
Himanshu Joshi

Reputation: 3399

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"]];

Upvotes: 0

Krivoblotsky
Krivoblotsky

Reputation: 1502

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.

Upvotes: 1

Related Questions