I have few UIViewControllers embeded in NavigationController, everything is cool when it comes to change screen titles, button titles, hiding/showing navigation bar (top bar) or toolbar (bottom bar), but - I cannot force toolbar buttons to have this animated shadow when pressed, as navigation bar buttons have. What's more, toolbar buttons are as black as toolbar - shouldn't button be slightly lighter color than toolbar?
I hope it's clear, because I couldn't find it nor even come up with reasonable title
If you want a black bar (navigation or toolbar), set its barStyle to UIBarStyleBlack in addition to or instead of tinting it black. This lets it know that the buttons should be tinted differently than if the bar was any other color.
I am not able to understand you whole problem but for the toolbar problem you can give those buttons different colors and also can give an effect of changing color of button which is clicked
UIBarButtonItem *toolBtn = [[UIBarButtonItem alloc] initWithTitle:#"Share and Upload"
style:UIBarButtonItemStyleBordered
target:self
action:#selector(your_Target)];
toolBtn.tintColor = [UIColor redColor];
Now suppose toolBtn is your first button in toolbar and on click of it you want to change its color then in your target function
-(void)your_Target{
UIBarButtonItem *button1 = [[your_Toolbar items] objectAtIndex:0];
button1.tintColor = [UIColor brownColor];
// or you can simply loop all toolbar buttons and change the color of only clicked one and for rest keep it default
}
Hope this will help you.. and sorry for my bad english :)
Related
I have a tool bar at the top and bottom of my application and I need to create buttons to put into the toolbars. The ones designing this application would like space placed between the buttons on the toolbar. Aside from manually coding in a position change for the buttons, is there a better way to accomplish this through Interface Builder?
You can add a bar button of type UIBarButtonSystemItemFlexibaleSpace in the place where you want the space.
UIBarButtonItem *barButton1 = ...
UIBarButtonItem *barButton2 = ...
UIBarButtonItem *flexibleSpaceBarButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
toolbar.items = [NSArray arrayWithObjects:barButton1,
flexibleSpaceBarButton,
barButton2, nil];
As EmptyStack wrote, you can use the UIBarButtonItemFlexibleSpace to create spaces between buttons. You can either use the code written above or do it in the Interface Builder. In IB you will have to place the toolbar and then you can find toolbar items if I remember correcly around the end of the items list. So you can add a flexible space item to the toolbar, play around with its width and then add a 'real' bar button to the toolbar. You can declare outlets and assign actions to the barbuttons just like for normal UIButtons.
i have a ToolBar in my view controller.i need to show one icon in right side of the ToolBar.
so i added a BarButton item and displayed icon image there.but the is a problem with icon color.it displaying as black which is not looking good and also cant able to arrange Barbutton items on right side of the Toolbar.can any one tell me a good way to do it.please help me to arrange barbuttonitems on right side and provide a way to give colors to BarButtonItem.
Use below below change the color of UIToolBar.
//Give your choice of color.
myToolbar.tintColor = [UIColor darkGrayColor];
To align the right button you need to use a bar button of type UIBarButtonSystemItemFlexibleSpace Read SO post.
Aligning UIToolBar items
I have a UITableView with a navigation bar on the top. I changed the style of the navigation bar to Black Opaque to go with my theme.
I added an edit button as well using the below line of code
self.navigationItem.leftBarButtonItem = self.editButtonItem;
All is fine so far, the edit button also appears in the balck opaque style.
however the done button appears in the default blue theme. Am i missing some simple thing? How should i change it?
Help would be appreciated
The done button is always blue on a UIBlackBarStyle Navigation bar, but will adjust its color if you use the tintColor property of the navigationBar to color it in your chose of colors. I haven't tried it, but an idea would be to set
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
this should give you a Black navigation bar with a black done Button.
However, for consistency reasons you can not directly set your custom background color on the done button.
I want a button tap effect for a UIBarButtonItem. My navigation bar has black tint color:
[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
So when I tap on any UIBarButtonItem on it, I do not get a button tapping effect. If I change the tint color to some other color like gray, it works. But I want only the black color there in the tint.
When you tap on a button, it color fades and you feel the tapping effect. That is because of touchUpInside action associated with UIButton class but nothing such event is there with UIBarButtonItem. I can get that effect with UIBarButtonItem if I set the Tint color of Navigaiton bar to other than black or dark gray.
Any suggestions.
You can always set your UIBarButtonItem custom view to a UIButton, then youll have whatever effect from UIButton that you like...
I got this done by setting the nav bae style:
myController.navigationBarStyle = UIBarStyleBlackOpaque;
I was wondering why everything stops behaving as it should when I do something like this:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
All my buttons on the navigationBar are now black regardless of style, like this one below, it should turn up as a blue button:
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:#"Edit" style:UIBarButtonItemStyleDone target:self action:#selector(editTrip)];
It does not, it is just black.
The slight change/effect in the button when tapped is also gone?
Is there a way to change the color of the navigationBar and maybe even the UIbarButtonItems without somehow ruining standard behavior?
This is really strange. I just checked with the Apple "Remote" app, it has the black navigation bar and a blue "Done" button for leaving the "help" section.
Do I really have to build everything custom to achieve this?
Thanks for any help given:)
In Interface Builder, change the Style of the Navigation Bar to Black Opaque or Black Translucent and leave the tint alone. This will give you a black bar with the standard blue buttons.
I'm sure the way to do this in code without Interface Builder, is by setting the barStyle property to UIBarStyleBlack or UIBarStyleBlackTranslucent, but I haven't done it that way.