Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of Image on UINavigationBar

I want to put Custom image on my UINavigationBar,

When i tried this two code snippets,

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

And

    UIButton *logoView = [[UIButton alloc] initWithFrame:CGRectMake(0,0,70,30)];
    [logoView setBackgroundImage:[UIImage imageNamed:@"logo.png"] forState:UIControlStateNormal];
    [logoView setUserInteractionEnabled:NO];
    self.navigationItem.titleView = logoView;

image which i can see on my Device is getting blur or it is getting streched.

I made image with Resolution of 180*40(Width*Height)

I want to know the exact size of Image. what, it would be ?

Thanks in advance.

like image 207
Krunal Avatar asked Jul 18 '13 09:07

Krunal


People also ask

What size should Icons be in a navigation bar?

Microsoft suggests you set your touch target size to 9 mm square or greater (48×48 pixels on a 135 PPI display at a 1.0x scaling). Avoid using touch targets that are less than 7 mm square. Touch targets shouldn't be smaller than 44px to 48px (or 11mm to 13mm), padding included.

How do I change the image on a navigation bar?

First you need to set the height and width of the parent element of the image. I just gave the div with id profile-image a height: 100px and width: 100px . Next you need to tell the <img /> tag to conform to these dimensions. We can do that by giving it a style of height: 100% and width: 100% .

How do I change the navigation bar height in Swift 4?

In order to increase the height of the navbar , you have to increase the size of the children > li > a . Keep in mind that the children already have vertical padding of 15px.


1 Answers

use this

UIImageView *navigationImage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 98, 34)];
navigationImage.image=[UIImage imageNamed:@"topNav-logo.png"];

UIImageView *workaroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 98, 34)];
    [workaroundImageView addSubview:navigationImage];
    self.navigationItem.titleView=workaroundImageView;

hope this helps.

like image 103
iEinstein Avatar answered Oct 21 '22 07:10

iEinstein