uitoolbar with icons/text similar to uitabbar - ios

Ideally I want to use a UIToolbar but I want the icons at the bottom to appear as they would in a UITabBar meaning with icon for default and highlighted states and title beneath. I know I can drag a UIButton onto the toolbar and it will create a UIButton inside of a UIBarButtonItem, but I can't seem to manipulate the UIButton to show a title beneath? The other problem I'm having is when I set the alignment of the button in IB (in the Control section) it only changes the alignment for the default state not the highlighted state. Can anyone give me some pointers here that would be great thanks!
rc

Putting the UIButton inside a UIBarButtonItem is the best way I've found to do it. Just set the text for the button and it should show up fine. When manipulating the positioning, remember you're manipulating the position of the UIBarButtonItem and not the UIButton. Hope that helps!

Related

iOS : subclassing UINavigationBar for custom title view

I've subclassed UINavigationBar, I wanted to have a UIView contains UIImageView + UILabel inside it, I'm able to achieve it by setting titleView property. But, what I want to know is whether its possible to add it inside subclass directly?
Better way add one UIView on Navigationbar and then add any component on that so it is easy to manage those component because if you add component on left button right button and title label it not that much flexible to customise (i.e. if you added any component on titleLabel you can set that component frame only equal or less that title label. but if you add on UIView on Navigation bar then you can customise all components easily)
I hope it will help you.

UIButton .selected doesn't cover whole width of button?

Edit: Here is the screenshot:
The button on the right is selected. I'd like the color to fill the entire button.
The buttons are created on storyboard with widths pinned. I simply toggle selected/not selected with
button.selected = YES;
I have not found any similar questions about adjusting the width of the part that is selected, and I haven't been able to figure out any solutions. Any ideas?
Make sure your UIButton's type is "Custom", not "System".

How do I achieve a navigation bar like the one used in iBooks?

The navigation bar in iBooks is exactly what I'm looking to implement. That is, a transparent top bar with the return button in the top left and some buttons in the top right to invoke actions.
However, I'm not exactly sure how this effect would be accomplished. The transparency especially. Can anyone point me in the right direction of how I might accomplish this?
Use a custom UIView subclass. Just add some buttons and set the alpha of the view. Use the controller's UINavigationController to push or pop controllers.The navigationbar should be hidden.
I would not use a navigationControllerBar, I would use a simple UIToolbar to do this. Especially you can have only two button on the navigationControllerBar (left and right button) unlike on a UIToolbar.
The UIToolbar is absolutely customizable, you can set the opacity to 0% and the opaque to NO, after it can be transparent....
With UIView or UIToolbar the alpha is fully customisable. You should subclass one of those two (UIView or UIToolbar), add your buttons and then go from there.

Creating a custom UINavigationbar for iPad in iOS 5 with ARC

I am creating an iPad application for ios 5 using arc and storyboard in xcode 4.3. I need to customize the UInavigationbar to make it broader than its usual size (almost double sized) and add to it some custom logos (images) and buttons. Can anyone pls point me in the correct direction on how this can be acheived? any third party libraries are also welcome if required.
Thanks in advance for your help on this one.
To start, you'll want to subclass UINavigationBar. While it is possible to change the height, the UINavigationBar background isn't going to play nicely, so you'll probably want to use your own background image.
Here's some information about resizing the navigation bar
Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch
iPhone - How set uinavigationbar height?
And another article on how to add the images and buttons as subviews.
http://www.iosdevnotes.com/2011/09/custom-uinavigationbars-techniques/
I don′t know how you would change the size of the UINavigation bar.
To add custom buttons you can outlet your navigationItem in the storyboard to the interface of your view controller. Then use setLeftBarButtonItems: and setRightBarButtonItems: to put multiple buttons you previously created.
To add custom black and white logos to the buttons you can use [navigationButtonItem setBackgroundImage: yourImage].
If you want your logos in color you can create a UIButton with the colored logo ([newButton setImage: yourImage]) and then init your navigation button item with : initWithCustomView: newButton.

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.

Resources