Adding a background image to UIBarButton Item using interface builder - Beginner - iphone

I added a UIToolBar from Interface builder, then dragged 2 UIBarButtonItem's. Now i need to add an image to it. So i selected the barButtonItem and selected the image using Interfacebuilder.
I only get a White image, with no curvy edge. My image is as follows. I don't see that image, but instead i see a white rectangle.
How do i prevent this. Can someone tell me whats wrong, and provide me with a working solution.
my bar button

If you go to iOS Human Interface Guidelines you will see the specifications for icons and buttons. This is my experience, for the best result you'd better create a specific icon (image) for UIBarButtonItem. If you still want to use an image, that doesn't follow the UIBarButtonItem guide, my approach is:
Add a generic UIButton instance to your view. Drag it from the list on the right to the view, not to the ToolBar or navBar.
Customize it with the image, i.e. from the Inspector, set the image or background image, or set it to custom style, bordered, etc.
Drag it to the toolBar, and XCode will adjust it. Again, it does not always guarantee the best result, but it does what you want.
I hope it helps.

You should drag an "Image View" on to your layout and specify the image in that - that worked for me, but I'm no xcode guru.
Hope that helps, Paul

Related

How To Create A Custom Center Tab Button?

I'm trying to follow this tutorial here to recreate a custom center tab button, but I already have my tabbarcontroller setup in IB. Can anyone help me do this? The tutorial does it all through code so its difficult to follow.
http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
All they're doing is creating a blank UITabBarItem, no image or name, simply a placeholder. They then put a UIButton with a custom image (i.e. the green camera button) on top of the UITabBar. Just go into interface builder and add a new TabBarItem and put a UIButton on top of it.

Really cool way to create custom UITabBar for iPhone app?

I am doing a lot of researching lately about how to get a different looking with nice effects UITabBar on my iPhone app, but unfortunately I am only finding things on how to replace background color etc.
Well, I've checked out this app called Momento which is pretty cool and presents a very slick tabBar:
So there are a couple of elements here I would like to ask you guys if you could help me by giving me the right directions on how to get a similar effect :)
Arrow above items: as you can see this app has this animated arrow that runs above the selected item with a very smooth animation.
Selected Stated of the item's image is not that blue-ish default one neither the default state which displays in a different shade of brown and gray version.
nice Items separators with beveled vertical lines.
different background image for the tabBar
different height for the tabBar
At this point after some research I am able to set the height and background image by subclassing UITabBarController but I'm still not sure on how to accomplish the other items specially the first one related to the nice arrow effect.
How do I do this? Please clarify what can or can't be done by subclassing the UITabBarController and specially if can be done in Interface Builder.
There's a project on github called BCTabBarController that aims to mimic the tab bar used in Twitter for iPhone. It's got some of the things you're looking for, and should give a great starting point.
Both of these are good answers, but both libraries have problems: BCTabBarController doesn't know how to create the "blue" highlighted version of a tab bar icon; and iDevRecipies doesn't send events to child viewcontrollers nor resize the navigation bar on rotate.
Be warned: custom nav bars are a lot of trial-and-error debugging (as I have found).
Simply use a UIView with TabBar width and height.Add custom background image and custom buttons on the view.Set the fileowner of the view as AppDelegate.Now you can simply connect the IBActions with the buttons.The Custom view can be placed over the tabbar by addSubView to the TabBar controller's view.You can switch between viewcontrollers by using the setSelectedIndex method of tableviewcontroller in the button action.

Custom UIToolBar from Images

I need to create a UIToolbar object that uses an image for the background. Most of the buttons are images as well, and rectangular. One button, however, is round and overlaps the toolbar like the Start button on the Windows task bar. See below.
I know that I will need to subclass the UIToolbar to paint the image for the toolbar -- I think. If so, does anyone have example code showing how to do this?
Furthermore, does anyone have any ideas on how to implement the larger round button? I'm thinking of another custom subclass for this, but not sure if there might be an easier way.
I can have the art guys chop the image anyway needed, which I'm sure the round button will need to be chopped some how.
Any ideas or sample code?
alt text http://iphone.sophtware.com/toolbar.png
Maybe you'll find some inspiration at this tutorial : Recreating The Raised Center Tab Bar Button of Instagram, DailyBooth & Path
For the color, you can experiment with the tintColor property.
As for the rest, UIToolbar is not designed for this. You will need a custom component (probably based on UIView).
I think it is possible but hard.
Override the drawRect method of the toolbar to draw the whole image. Then add left and right buttons.
For the round button you can add one invisible button on the bottom middle of the View and another invisible button in the middle of toolbar. Of course, you can try to use the views instead of the buttons and track the user interaction manually.

iPhone - Custom Tab Icons, Remove Highlight

I am creating a custom tab bar for my iPhone app and I need to change the images. I have changed the actual tab bar background, but I need to know how to add custom images for the icons and their respective "selected" icons. I also need to remove the square highlight that is default. Pretty much, it just needs to be my icons. Also wondering if the images can be coloured or not. I've looked a lot of this, but no one seems to have the solution.
Someone please help.
hide the inbuilt tabBar view
create your own custom UIView (or UIScrollView in case if you need more number of tabs) with the frame of inbuilt tabBar view and fill up, especially with array of UIButtons & then add your custom view as a subview of the TabBarController.
Play with the UIButton's background image (which is your tab icon image) and its addTarget:action:forControlEvents: in order to set the appropriate selectedIndex value of the TabBarController, i.e. set the selectedIndex according to the button's position in the custom view.
This is how I've implemented :)
No. You cannot customise the tab bar icons in the UITabBar.
They are designed to be used with an alpha masked image.
Someone discovered a way to hack the colours though here: Custom colors in UITabBar

iPhone dev: adding an overlapping label to the image

I'm trying to figure out a best way to implement the picture-editing capability shown in the native address book app on iPhone.
On the built-in address book, this is how the picture looks like before editing:
qkpic.com/2f7d4 http://qkpic.com/2f7d4
And after clicking edit, notice how "Edit" overlay is added and the image becomes clickable:
qkpic.com/fb2f4 http://qkpic.com/fb2f4
What would be the best way to implement something like this? Should I make the image a button from the beginning and have tapping disabled at first? If so, what steps are required to add an overlay/label to the image (in above example, gray border + the text "Edit" is added)
The easiest way is to use Interface Builder, create a container view, then add a UIImageView and UILabel as subviews to it. You would position and style the text and the image but set the UILabel to hidden. Make the whole container view respond to touches. It's easy to do since UIView is derived from UIResponder so all you have to do is override touchesEnded. Whenever you want to change the text label, just set the UILabel to hidden=NO.
There's more to it, however. Notice how the image has rounded corners? You'll want to override the UIImageView's drawRect method to implement a custom drawing routine to do that. There's lots of sample code around and it wasn't part of your original question so I'll stop here.