Setting custom UIControl/UIButton Color per 'isEnabled' UIControl property - ios

Goal: Customize the color used to indicate a button's 'isEnabled' boolean value.
Scenario: Normally a button is dimmed when disabled. However I've been requested to use a custom color to indicate a disabled button.
Question: How would I do that?
Does a button/controller's traits offer such option?
Or do I have to juryrig my own function?

Related

Setting UITextField Background in Attribute Inspector

According to the documentation, background property is
The image that represents the background appearance of the text field
when it is enabled.
In the attribute inspector there is a Background Dropdown with a lot of items to choose from, but no matter what I choose, nothing happens if done for the UITextField. If done for a UIButton, it is working fine.
Update: the question is not about setting the background color in code. It is about why does choosing any item from the drop down in attribute inspector does not have any effect for the UITextField.
You can change UItextfield background color through code like this:
textField.backgroundColor = backgroundColor;

How to set layout for UIButton in storyboard for different states?

Is there a way how to customise UIButton in interface builder for different states of that button?
Yes, it is possible, let's say this is the default state:
Now let's change the title for highlighted state:
This is how it looks before I press the button:
...and after:
You can do the same for every property of the button.
Note: default and highlighted states are controlled automatically, but selected and disabled you have to control manually.

UIButton Image Not Changing With Interface Builder Settings (Selected & Disabled)

I am trying to set the toggle state of a UIButton through the interface builder. I have done it successfully using code, but I need to get it working through the interface builder.
Im not sure what the issue is but for selected I set its image to 'flashOn' and for disabled I set it to 'flashOff'
When I hold down the image, it shows the 2nd image, but pressing the image does not toggle between these two images.
Im certain it's super simple so if you can suggest what I am missing I would appreciate it
A button's selected and disabled states need to be set in code.
Can you show your implementation for when you got desired results through code? I think, from what I can piece together from your question, that you have mixed up the states of the button.
Default - images will display for this button in any state unless another is specified explicitely
Disabled - image will display when button is disabled. (button will not switch from this state through user interaction as it is disabled)
Selected - image will display when the button is selected, which as far as I know is only when you set the button as selected through code.
Highlighted - image will display when you press and hold down on the button

How can I set the Backgoundcolor of an AX2012 Action Pane Button

I'm trying to set the background color of an Action Pane Button so I changed the init-Method to this:
public void init()
{
super();
myButton.colorScheme(FormColorScheme::RGB);
myButton.backgroundColor(WinAPI::RGB2int(255,0,0));
}
but myButton (AutoDeclaration is on) does not become red.
Even when I set these properties by hand, the color does not change.
The Button has an Action, where the Image is defined. But removing that won't help.
It isn't possible to provide a custom background color for buttons in the action pane.
If you just want the button to look different, you can set the ToogleButton property to Check and the ToggleValue property to On to give it a difference appearance, you will also need to add code in the clicked method for the button to prevent it toggling to Off. This will give the button a different background color, but you won't have any control over the color used.

Detect second click on a segment

According to the documentation, the event which should related to UISegmentedControl is value changed. Assuming I have a segmented control with previous and next, in my case I should be able to click next more than one time, the default behaviour of UISegmentedControl will not recognize the successif second click on same segment. SO how to deal with that?
Set the momentary property of your UISegmentedControl to TRUE.
You can do that in code or in Interface Builder (there is a checkbox in the Attributes Inspector).

Resources