can't set image for Bar Button Item - ios

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 ,

Related

The image for my UIBarButtonItem keeps stretching to the center?

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.

Customising UIBarButton Item Image

So I am trying to customize a bar button item for this slideoutmenu I am creating. I want it to be a particular image. However I am having trouble doing this. Whenever I try to change the image programatically by saying
menuButton.image = UIImage(named: "myImage.png")
It appears to be all stretched. Whenever I tell it to be set to an image using the attribute inspector, it will do the same thing, and I am unable to resize it in the Main Storyboard and interface builder. I imagine the fix to be simple, but I am unable to figure it out. Is there possibly a way to customize the size of the navigation controller to give it more room? Does anybody have any ideas?
I misunderstood the question originally. It sounds like what you are asking is how you resize the image, because it's all stretched out. It might take a little adjusting, but you can set the image insets on the UIBarButtonItem programmatically:
menuButton.imageInsets = UIEdgeInsetsMake(5, 5, 5, 5)
This is just telling the button to draw the image inset 5pts from the top, 5pts from the left, 5pts from the bottom, and 5pts from the right. You can tweak those values until it looks how you wish.

Why does the UINavigationBar cut off part of my UIBuilder but not cut it off when tested?

As you can see in the image (in the UIBuilder), the UINavigationBar takes up probably 60px of space at the top, but that does NOT show up in the simulator. The image you see above it how I have to put those view in order for them to be as far from the top of the status bar as they are from the sides. How can I fix this?
As suggested by user vaibhav, this fixed the issue.
You need to click on your main view, go to attribute inspector, and un-click 'Adjust Scroll View Insets'. That is all. Thanks for the help!

Button image in navigation bar has different appearance. Why?

I'm trying to put a UIBarButtonItem with a custom image on a UINavigationBar. When I do however, the image doesn't look right. I want the button on the navigation bar to look like the one below it.
(This is a screenshot from the simulator, by the way, not Interface Builder)
I created the custom UIBarButtonItem by creating a UIButton, using the cog-wheel image as a background, and then simply dragging it to the the right bar button item place in Interface Builder. Seeing as creating a UIBarButtonItem programmatically with the aforementioned UIButton as its 'custom view' (-initWithCustomView) has the same result, I believe this is what is happening as well.
What I don't understand is why the button image lost its nice edges and color gradient when I added it to the navigation bar wrapped in a bar button item. Can anyone tell me?
Thanks in advance.
The image hasn't changed. It is the same. Its just that when put on different backgrounds, it is showing differently. You should consider increasing the contrast.

How to add a grey description bar under UINavigationBar?

Like this one
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284862083&mt=8&ign-mpt=uo%3D4
The grey bar with text "Most E-Mailed..." will always stay on top when the user scroll the content.
Can anyone give me an idea how to make this?
You can simply add an imageview with this image and set a label on it with what text you wanna display. I think this is what you want.
Here's a blog entry by someone who dissects how the NYTimes app was made: http://www.cocoanetics.com/2010/12/bars-like-the-new-york-times-app/

Resources