The image for my UIBarButtonItem keeps stretching to the center? - ios

I am trying to add a basic Settings icon in the top right of the navigation bar. I added a UIBarButtonItem to my navigation bar. Then I set the image, but it moved the image to the center instead of staying in the right? Is there a way to fix this?

Update: I fixed this by decreasing the dimensions of the icon closer to 40x40. It was too large.

Related

Is there a way for a logo image to have a greater height than the navigation bar and still be fully visible?

I have a situation where I need to create something like this:
The problem is that the logo is higher than the navigation bar is, and I want this all to be a part of the navigation bar. I’ve tried “pushing” the logo from the top, but it doesn’t really work. If I increase the height of the logo image, it just cuts it off where the navigation bar ends.
Also, the back button should be aligned to the top of the logo image.
Currently I am using a custom view for this and hiding the navigation bar, which I hate, so if anyone has any advice/suggestions it would be greatly appreciated!
Thanks!
Try setting title view's clip to bounds and masks to bounds to false by setting
self.navigationItem.titleView?.clipsToBounds = false
self.navigationItem.titleView?.layer.masksToBounds = false

Shifting backButtonImage horizontally

What I need,
What I get, on adding backButtonImage,
I want to shift the backButtonImage horizontally? No answers on here seem to work for me.
Any suggestions will be welcomed.
EDIT
I am just setting back image and back mask in storyboard, here it is (nav_back)
Have a look at UIBarButtonItem Size Inspector in storyboard.
You should be able to shift image to the right by X points by setting image left inset to X and right inset to -X. This worked with bar button item with custom image but not sure if it will with default back button

Not enough button space in Nav Bar

I am using the Navigation bar and I am putting in a button, which has a background color. The button looks large in the editor but is very small when I run the program. I tried adjusting the width and it does not let me set constraints, so I am stumped on how to make a larger button in the Navigation bar.
This worked for me. Edit the values in the size inspector tab.

can't set image for Bar Button Item

I'm using Objective-C. In Xcode, I set a image(.png) to a navigation bar button item. But no matter how I change the resolution of the image, it always going to be a blue pic, big or small.
It looks like this(the right top corner):
Does the picture cause the problem? How to solve it? Thanks in advance!
It is because of Barbutton's size is fixed.
So , my advice is add UIView as Barbutton item and then add UIButton and set image According to your required size.
Check output in below image.
Your Hierarchy will be something like this ,

Changing only the position of the default backBarButtonItem

So I have a custom nav bar in my iPad app which is a bit larger than the default 44 pixel bar (52 pixels tall). I want all the items in the nav bar to be center aligned which I have been able to do just fine with the exception of one item, the back button. I don't want to use a custom back button and instead just use the default one and just nudge its position down a bit so that its aligned with the center of my navbar. I haven't been able to find a clear answer to this and am not sure if its even possible. Anybody done something like this?
http://cl.ly/image/0g3f2M260B3C
UPDATE :
This can be done and I found the answer here : UIBarButtonItem Offset?
Ok well,but we can't change the custom back button position so try to implement that one also by custom.
By default back button position was center so we can't change that position.

Resources