I would like to place a logo/image in the left side of NavigationBar
. I try this in codes, but it is not worked properly.
UIImage *logo = [UIImage imageNamed:@"logo.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: logo];
imageView.frame = CGRectMake(2, 2, 40, 40);
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:logo];
I try with view to be placed first then place image as UIImageView but alignment is not good. And moreover view appears to be white space while run the code..
What I usually do is
I had the same problem in my last project, you can create a new logo.png which dimension is equal to 500*88 pixels, make you logo in the left side of it. filled with transparent color from the rest of the png.
hope this helpful.
Try it like this:
Also make sure UIImage is not nil and it does have a valid image.
Insert the
Bar Button Item
into yourViewcontroller
on left Side, and insert the image inBar item
see the imageI think this is the problem with image rendering mode. Can you try the below code
You can even try with your current code by setting the
UIImageRenderingModeAlwaysOriginal
.