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;
Related
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 :)
I'm trying to set the tintColor of a UIBarButtonItem in method that gets called when my program starts. I set up all my views using storyboards. I then customize the appearance of the views using the new iOS5 guidelines for using appearance proxies. I've customized the background of the navigation bar by doing the following:
- (void)customizeAppearance
{
UIImage *leatherTexture = [[UIImage imageNamed:#"BrownLeather#2x.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UINavigationBar appearance] setBackgroundImage:leatherTexture
forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:leatherTexture
forBarMetrics:UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setTintColor:[UIColor clearColor]];
}
I was hoping that by setting the UIBarButtonItem tintColor to clear would allow me to easily use the default button styles while having a custom background texture. However, setting the tintColor to clear just turns the button black as opposed to being transparent or clear. Any ideas what I'm doing wrong? Is there a way to create a clear button without having to use custom images for the buttons? See the image below:
You can't do this way (because IMO the default background of UIBarButtonItem is black. and new tint color is over-layered on it).
However you can customize your UIBarButtonItem with using UIButton (with background) as customView in UIBarButtonItem.
Or if you are targeting iOS 5 only you can use brown tint color (which will be flat and will not show background image)
Just found out that in Xcode 4.5 you can just drag a UIButton into the UIBarButton in the Storyboard. The UIButton is then fully customizable.
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 have a toolbar with a UIBarButtonItem with style: UIBarButtonItemStylePlain.
I wonder how can I disable the light that appears while touching it?
UIButton has showsTouchWhenHighlighted property but there is no such a thing for UIBarButtonItem is there a work-around you might know?
In Interface Builder drag a UIButton to the toolbar. It will create a UIBarButtonItem with a UIButton in it. Set the type of the UIButton to custom. Then you can fully customize the appearence. For example change the text color to white and the background color to transparent and of course disable the highlighting.
You can also drop in a UITextField and make it non-editable.
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.