Clear button color on text field - iphone

How do you change the clear button color of a UITextField?

You want to use rightView and rightViewMode. Use a button and add an image that is a red clear button. Then add your target and perform your logic.
rightViewRectForBounds will also return the size of the button for the rightView.

Related

Highlighting the selected cell in grid layout in unity

I am using a panel as grid lay out and a button prefab in that lay out.I can able to attach event for the button but i couldn't able to figure out how to highlight that button when user clicks on that button.Is there any way to change background color of that clone button when user clicks on that?
you can use onClick to call a method when the button is clicked.
public Button btn;
void Start () {
btn.onClick.AddListener(ChangeColor);
}
or just use the editor, OnClick list, just note that for this, the method you want to call should be public
if you just want to highlight the button which is currently clicked and when the user clicks on another button the other button gets highlighted and this button gets back to its normal color, then that option is simply doable in the editor, just set the highlight color of the button in the editor
but if you want the buttons to change their colors after you click on them and that change is permanent then
you can just change the color of the image property of the button, by accessing its Image property and set its color to something you want.
void changeColor(){
pButton.GetComponent<Image>().color = yourColor;
}
if you dont need to change the color of the image which is used in the button, but you want to change the Button normalcolor, first you keep your previous colors, then just set the new color to the normalcolor
I also think if you want to use this method it is better to change the highlightedColor too, because after the button is pressed it, after it goes to pressed color for a second, it will enter the highlighted state until you click on another button, so I guess it is better if you change both of the colors
public void ChangeColor()
{
ColorBlock colorBlock = btn.colors;
colorBlock.normalColor = Color.blue;
colorBlock.highlightedColor = Color.blue;
btn.colors = colorBlock;
}

iPhone UIButton provide different inset values for highlighted state

I want my titleLabel text move a little down on button tap (i.e. I want to give different inset values for highlighted and default states).
I have custom button background images and the button goes down in highlighted state image but the text on it stands at the same place so it gives a bad effect and looks like the text is seperated from button.
Is there any way to solve this?
Thanks in advance
The easiest way to do this is to put your text on the button's background image.
If you can't do that for some reason you can try to add IBAction on Button down and adjust button.titleLabel.frame.

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.

Clear background color of delete button

I have background image for every cell of table view, when i swipe delete button appears, the problem is that a square of white color(default cell color) appears behind the delete button, i want to get rid of that white square, so how to clear background color of delete button?
If u have create button dynamically then use react round type button. if u have same problem then u choose custom type button. If u have drag and drop then unchecked opaque quality of button in view section.

uibutton property to avoid highlights

At the time of click a button it's highlighted. While click the button i want to avoid the highlighting of button.
In my Application background image for the button is square shape if i'm click the button it shows square outline of the button.but my button is customtype only....
Please help me out to solve this....
Thank you
Renya
Try setting button's adjustsImageWhenHighlighted property to NO
set adjustsImageWhenHighlighted property to YES...
it will avoid the highlight of UIButton
If you are creating button using Interface Builder..
Inside the button Attribute Inspector ..
On the top .. there is drop down box.. which has different states of the button
like Default, Highlighted, Selected etc.. you can set Button's behavior here..
Did you try adding :
[ homebut setHighlighted:NO ];
?