Disable touch animation in UIButton in iPhone - iphone

I want to disable the animation of button is touch down or selection. I want to mimic the feature that selection is happening on label. I am comfortable with the properties of button compare to uilabel because i can give my background image and it also help me in more issues.
Please help me in this?

I think what you need is to unselect the "Highlighted adjusts image" option in Interface Builder:

Disable the user interaction of your button.
myButton.userInteractionEnabled = NO;

2018 people, Swift 4.0:
Setting the button's adjustsImageWhenHighlighted property worked. Need this in my custom UITabBarController (e.g. large center tabBarItem).

set your button type as custom.
myButton.buttonType = UIButtonTypeCustom;

Related

Custom UIBarButtonItem highlight issue

I have a toolbar with 5 buttons.
4 of them are regular bar button items and one of them is a custom one (A 'UIButton' inside a 'UIBarButtonItem').
I noticed that when I click between the regular buttons (not exactly on them), one of them (the closest one) still recieves the click event and is being highlighted (which is what I want).
But the custom bar button item does not show this behaviour.
When I tap between it and one of the regular buttons neither of the 2 receives the touch event. This probably because the UIButton is the one the gets the click event. Is there a way to add a touch event the containing bar button item as well? Or perhaps another way to solve this?
Thanks!
button.userInteractionEnabled = YES; I believe is the answer.
One solution might be that you create image of same as bar button item and assign to UIButton as background image, this will solve your issue.
Hope this helps you....
Solved it!
I added another UIView to the UIBarButtonItem and then I added the UIButton to the UIView.
I added a touch gesture to the UIView (And also kept the original touch event of the UIButton) that expanded the area that you can touch the button which solved the problem.

UIButton sets dark when it is selected (I want to avoid this)

I'm developing an iOS 4 application.
I'm using a custom uibutton to make an image clickable. When user taps over the image, it will disappear.
It's not very pretty to see that the image gets black, then turns to its original color, and then disappear.
Is there a way to disable that effect?
You will need to set the property adjustsImageWhenHighlighted to NO:
[button setAdjustsImageWhenHighlighted:NO];
Alternatively you can set the same image for all controlStates of the button.
You need to set the property Shows Touch On Highlight to enabled.
Programmatically you can do that with:
[button setShowsTouchWhenHighlighted:YES];
Since it's a custom button, you get to specify the image you want to show when it's highlighted. Create the image you want to show in that situation.
If you are using interface builder just set the Highlighted and selected states to the same image as the default image.

How can I prevent a UIButton from highlighting when pressed?

When an UIButton is pressed, the normal situation is that it will be highlighted i.e. a shadow like layer will cover the image. Is there a way to prevent this from happening? Is there an attribute to handle this?
You normally don't press a button with Xcode, you use your finger (or mouse). But nitpicking aside: adjustsImageWhenHighlighted set to NO will do the trick.
If you make a custom subclass of the UIButton you can override setHighlighted:(BOOL)highlighted to do nothing
- (void)setHighlighted:(BOOL)highlighted
{
return;
}
You can also achieve this through Interface Builder. Uncheck "Highlighted Adjusts Image" in the Attributes inspector.

touch effect for Button in iphone

how can i just change the color,of a button when i set the focus on the button in iphone.
I mean to say , for example we have 5 buttons, and i am just setting the focus on each of the button. i want those buttons to be higlighted with different color.
but when press or touch up inside the utton, the navigation is made to the respective forms, that is set for that button.
you can write method, for example, let it be
- (void) changeButtonState:(UIButton*) buttonToChange;
then you can call it in your onBtnClk method for button you need. in that method you can change image for your button's UIControlStateNormal mode. and if I understand right, you can use toolbar or tabbar instead of buttons.
Guess you have already asked this issue differently here..
But have you checked the answer?? You can use any of those methods at your will!

How can I change the default color of the button on iPhone when pressed?

The default color when a button is pressed on Iphone is blue. How can I change to some other color?
The same applies to the case when I select a row of UITableViewCell. How can I change the color when selected?
Thanks.
In the case of the UIButton, I think you need to provide your own images for the highlighted state. Many of the controls in the iPhone OS like the UIToolbar and UINavigationBar provide a "tint color" that you can change to customize their appearance. The UIButton has a couple of predefined appearances, like "Rounded Button", but most of the time I end up using custom images for mine.
I'm not sure about the UITableViewCell - you might need to subclass it and draw the selected state yourself. There may be a "background image for state" that you could change instead, though.
Sorry that's really not the best news. Maybe someone else knows a better way?